예제 #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;
 }