use of alien4cloud.plugin.model.ManagedPlugin in project alien4cloud by alien4cloud.
the class PluginManager method unloadPlugin.
private void unloadPlugin(String pluginId, boolean disable, boolean remove) {
ManagedPlugin managedPlugin = pluginContexts.get(pluginId);
if (managedPlugin != null) {
// send events to plugin loading callbacks
for (IPluginLoadingCallback callback : SpringUtils.getBeansOfType(alienContext, IPluginLoadingCallback.class)) {
callback.onPluginClosed(managedPlugin);
}
managedPlugin.getPluginContext().stop();
// destroy the plugin context
managedPlugin.getPluginContext().destroy();
}
// unlink the plugin
for (PluginLinker linker : linkers) {
linker.linker.unlink(pluginId);
}
// eventually remove it from elastic search and disk.
if (remove) {
removePlugin(pluginId, true);
} else if (disable) {
disablePlugin(pluginId);
}
pluginContexts.remove(pluginId);
}
use of alien4cloud.plugin.model.ManagedPlugin in project alien4cloud by alien4cloud.
the class UiController method modules.
/**
* Get the list of modules to be loaded.
*
* @return The list of modules to be loaded.
*/
@ApiOperation(value = "Get the list of ui modules to be loaded.")
@RequestMapping(value = "", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public Map<String, PluginInfo> modules() {
Map<String, ManagedPlugin> plugins = pluginManager.getPluginContexts();
Map<String, PluginInfo> entryPoints = Maps.newHashMap();
for (ManagedPlugin managedPlugin : plugins.values()) {
Plugin plugin = managedPlugin.getPlugin();
String uiEntryPoint = plugin.getDescriptor().getUiEntryPoint();
if (uiEntryPoint != null) {
String pluginBase = root + plugin.getPluginPathId() + "/";
String entryPoint = pluginBase + uiEntryPoint;
entryPoints.put(managedPlugin.getPlugin().getDescriptor().getId(), new PluginInfo(entryPoint, pluginBase));
}
}
return entryPoints;
}
use of alien4cloud.plugin.model.ManagedPlugin in project alien4cloud by alien4cloud.
the class PluginManager method disablePlugin.
/**
* Disable a plugin.
*
* @param pluginId The id of the plugin to disable.
* @param remove If true the plugin is not only disabled but also removed from the plugin repository.
* @return Empty list if the plugin was successfully disabled (and removed), or a list of usages that prevent the plugin to be disabled/removed.
*/
public List<PluginUsage> disablePlugin(String pluginId, boolean remove) {
List<PluginUsage> usages = Lists.newArrayList();
ManagedPlugin managedPlugin = pluginContexts.get(pluginId);
if (managedPlugin != null) {
for (PluginLinker linker : linkers) {
usages.addAll(safe(linker.linker.usage(pluginId)));
}
}
if (usages.isEmpty()) {
unloadPlugin(pluginId, true, remove);
}
return usages;
}
use of alien4cloud.plugin.model.ManagedPlugin in project alien4cloud by alien4cloud.
the class PluginManager method loadPlugin.
/**
* Actually load and link a plugin in Alien 4 Cloud.
*
* @param plugin The plugin the load and link.
* @param pluginPath The path to the directory that contains the un-zipped plugin.
* @param pluginUiPath The path in which the ui files are located.
* @throws IOException In case there is an IO issue with the file.
* @throws ClassNotFoundException If we cannot load the class
*/
private void loadPlugin(Plugin plugin, Path pluginPath, Path pluginUiPath) throws IOException, ClassNotFoundException {
// get the plugin spring context, start it
AnnotationConfigApplicationContext pluginContext = getPluginContext(plugin, pluginPath, pluginUiPath);
ManagedPlugin managedPlugin = (ManagedPlugin) pluginContext.getBean("alien-plugin-context");
Map<String, PluginComponentDescriptor> componentDescriptors = getPluginComponentDescriptorAsMap(plugin);
// expose plugin elements so they are available to plugins that depends from them.
expose(managedPlugin, componentDescriptors);
// register plugin elements in Alien
link(plugin, managedPlugin, componentDescriptors);
// install static resources to be available for the application.
pluginContexts.put(plugin.getId(), managedPlugin);
}
Aggregations