List<Module> pluginModules = new ArrayList<Module>();
ClassLoader classLoader = getClass().getClassLoader();
ServiceLoader<RuntimePlugin> services = ServiceLoader.load(RuntimePlugin.class, EmbeddedRuntime.class.getClassLoader());
Iterator<RuntimePlugin> iterator = services.iterator();
while (iterator.hasNext()) {
RuntimePlugin plugin = iterator.next();
try {
Module module = plugin.installPluginModule(this, classLoader);
if (module != null) {
pluginModules.add(module);
}
} catch (ModuleException ex) {
LOGGER.error("Cannot load plugin: " + plugin.getClass().getName(), ex);
}
}
// Start the plugin modules
for (Module module : pluginModules) {