/** * Loads plugins from directory {@literal webRoot/plugins/}. */ public void load() { Stopwatchs.start("Load Plugins"); classLoaders.clear(); final ServletContext servletContext = AbstractServletListener.getServletContext(); final Set<String> pluginDirPaths = servletContext.getResourcePaths("/plugins"); final List<AbstractPlugin> plugins = new ArrayList<>(); if (null != pluginDirPaths) { for (final String pluginDirPath : pluginDirPaths) { try { LOGGER.log(Level.INFO, "Loading plugin under directory[{0}]", pluginDirPath); final AbstractPlugin plugin = load(pluginDirPath, pluginCache); if (plugin != null) { plugins.add(plugin); } } catch (final Exception e) { LOGGER.log(Level.WARN, "Load plugin under directory[" + pluginDirPath + "] failed", e); } } } eventManager.fireEventSynchronously(new Event<>(PLUGIN_LOADED_EVENT, plugins)); Stopwatchs.end(); }
/** * Loads plugins from directory {@literal webRoot/plugins/}. */ public void load() { Stopwatchs.start("Load Plugins"); classLoaders.clear(); final ServletContext servletContext = AbstractServletListener.getServletContext(); final Set<String> pluginDirPaths = servletContext.getResourcePaths("/plugins"); final List<AbstractPlugin> plugins = new ArrayList<>(); if (null != pluginDirPaths) { for (final String pluginDirPath : pluginDirPaths) { try { LOGGER.log(Level.INFO, "Loading plugin under directory[{0}]", pluginDirPath); final AbstractPlugin plugin = load(pluginDirPath, pluginCache); if (plugin != null) { plugins.add(plugin); } } catch (final Exception e) { LOGGER.log(Level.WARN, "Load plugin under directory[" + pluginDirPath + "] failed", e); } } } eventManager.fireEventSynchronously(new Event<>(PLUGIN_LOADED_EVENT, plugins)); Stopwatchs.end(); }