Search in sources :

Example 1 with SimplePluginManager

use of org.nutz.plugin.SimplePluginManager in project nutz by nutzam.

the class CustomMake method init.

/**
     * 加载插件
     */
@SuppressWarnings({ "unchecked", "rawtypes" })
public CustomMake init() {
    List<String> plug = (List<String>) ((Map) NutConf.get("EL")).get("custom");
    String[] t = plug.toArray(new String[0]);
    PluginManager<RunMethod> rm = new SimplePluginManager<RunMethod>(t);
    for (RunMethod r : rm.gets()) {
        me().runms.put(r.fetchSelf(), r);
    }
    return this;
}
Also used : RunMethod(org.nutz.el.opt.RunMethod) List(java.util.List) SimplePluginManager(org.nutz.plugin.SimplePluginManager)

Example 2 with SimplePluginManager

use of org.nutz.plugin.SimplePluginManager in project nutz by nutzam.

the class Logs method init.

/**
     * 初始化NutLog,检查全部Log的可用性,选择可用的Log适配器
     * <p/>
     * <b>加载本类时,该方法已经在静态构造函数中调用,用户无需主动调用.</b>
     * <p/>
     * <b>除非迫不得已,请不要调用本方法<b/>
     * <p/>
     */
public static void init() {
    try {
        String packageName = Logs.class.getPackage().getName() + ".impl.";
        adapter = new SimplePluginManager<LogAdapter>(packageName + "CustomLogAdapter", packageName + "Slf4jLogAdapter", packageName + "Log4jLogAdapter", packageName + "SystemLogAdapter").get();
    } catch (Throwable e) {
        try {
            Log4jLogAdapter tmp = new Log4jLogAdapter();
            if (tmp.canWork())
                adapter = tmp;
            else
                adapter = new SystemLogAdapter();
        } catch (Throwable _e) {
            adapter = new SystemLogAdapter();
        }
    }
}
Also used : Log4jLogAdapter(org.nutz.log.impl.Log4jLogAdapter) SystemLogAdapter(org.nutz.log.impl.SystemLogAdapter) SimplePluginManager(org.nutz.plugin.SimplePluginManager)

Aggregations

SimplePluginManager (org.nutz.plugin.SimplePluginManager)2 List (java.util.List)1 RunMethod (org.nutz.el.opt.RunMethod)1 Log4jLogAdapter (org.nutz.log.impl.Log4jLogAdapter)1 SystemLogAdapter (org.nutz.log.impl.SystemLogAdapter)1