Search in sources :

Example 1 with ManagedPlugin

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);
}
Also used : ManagedPlugin(alien4cloud.plugin.model.ManagedPlugin)

Example 2 with ManagedPlugin

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;
}
Also used : ManagedPlugin(alien4cloud.plugin.model.ManagedPlugin) Plugin(alien4cloud.plugin.Plugin) ManagedPlugin(alien4cloud.plugin.model.ManagedPlugin) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with ManagedPlugin

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;
}
Also used : PluginUsage(alien4cloud.plugin.model.PluginUsage) ManagedPlugin(alien4cloud.plugin.model.ManagedPlugin)

Example 4 with ManagedPlugin

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);
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) PluginComponentDescriptor(alien4cloud.plugin.model.PluginComponentDescriptor) ManagedPlugin(alien4cloud.plugin.model.ManagedPlugin)

Aggregations

ManagedPlugin (alien4cloud.plugin.model.ManagedPlugin)4 Plugin (alien4cloud.plugin.Plugin)1 PluginComponentDescriptor (alien4cloud.plugin.model.PluginComponentDescriptor)1 PluginUsage (alien4cloud.plugin.model.PluginUsage)1 ApiOperation (io.swagger.annotations.ApiOperation)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1