Пример #1
0
 public Collection<Class<? extends CloseableIndexComponent>> indexServices() {
   List<Class<? extends CloseableIndexComponent>> services = Lists.newArrayList();
   for (Plugin plugin : plugins.values()) {
     services.addAll(plugin.indexServices());
   }
   return services;
 }
Пример #2
0
 public Collection<Class<? extends LifecycleComponent>> services() {
   List<Class<? extends LifecycleComponent>> services = Lists.newArrayList();
   for (Plugin plugin : plugins.values()) {
     services.addAll(plugin.services());
   }
   return services;
 }
Пример #3
0
 public Collection<Class<? extends Module>> indexModules() {
   List<Class<? extends Module>> modules = Lists.newArrayList();
   for (Plugin plugin : plugins.values()) {
     modules.addAll(plugin.indexModules());
   }
   return modules;
 }
Пример #4
0
 private Map<String, Plugin> loadPluginsFromClasspath(Settings settings) {
   Map<String, Plugin> plugins = newHashMap();
   Enumeration<URL> pluginUrls = null;
   try {
     pluginUrls = settings.getClassLoader().getResources("es-plugin.properties");
   } catch (IOException e) {
     logger.warn("Failed to find plugins from classpath", e);
   }
   while (pluginUrls.hasMoreElements()) {
     URL pluginUrl = pluginUrls.nextElement();
     Properties pluginProps = new Properties();
     InputStream is = null;
     try {
       is = pluginUrl.openStream();
       pluginProps.load(is);
       String sPluginClass = pluginProps.getProperty("plugin");
       Class<?> pluginClass = settings.getClassLoader().loadClass(sPluginClass);
       Plugin plugin = (Plugin) pluginClass.newInstance();
       plugins.put(plugin.name(), plugin);
     } catch (Exception e) {
       logger.warn("Failed to load plugin from [" + pluginUrl + "]", e);
     } finally {
       if (is != null) {
         try {
           is.close();
         } catch (IOException e) {
           // ignore
         }
       }
     }
   }
   return plugins;
 }