Ejemplo n.º 1
0
 /** 查找Module(由Module初始化的子Module不再查找范围内)。 */
 protected Module[] findModules() {
   ArrayList<String> moduleTyleList = new ArrayList<String>();
   Environment env = this.getEnvironment();
   boolean loadModule = env.getSettings().getBoolean("hasor.modules.loadModule", true);
   if (loadModule) {
     List<XmlNode> allModules = env.getSettings().merageXmlNode("hasor.modules", "module");
     for (XmlNode module : allModules) {
       String moduleTypeString = module.getText();
       if (StringUtils.isBlank(moduleTypeString)) {
         continue;
       }
       if (!moduleTyleList.contains(moduleTypeString)) {
         moduleTyleList.add(moduleTypeString);
       }
     }
   }
   //
   ArrayList<Module> moduleList = new ArrayList<Module>();
   for (String modStr : moduleTyleList) {
     try {
       ClassLoader loader = Thread.currentThread().getContextClassLoader();
       Class<?> moduleType = ClassUtils.getClass(loader, modStr);
       moduleList.add((Module) moduleType.newInstance());
     } catch (Throwable e) {
       logger.warn(
           "load module Type {} is failure. -> {}:{}", modStr, e.getClass(), e.getMessage());
       if (this.getEnvironment().isDebug()) logger.error(e.getMessage(), e);
     }
   }
   return moduleList.toArray(new Module[moduleList.size()]);
 }
Ejemplo n.º 2
0
 public StandardEventManager(Environment env) {
   env = Hasor.assertIsNotNull(env, "Environment type parameter is empty!");
   this.settings = env.getSettings();
   this.executorService = Executors.newScheduledThreadPool(1);
   env.addSettingsListener(
       new SettingsListener() {
         public void reload(Settings newConfig) {
           update();
         }
       });
   this.update();
 }