use of alien4cloud.plugin.model.PluginComponentDescriptor in project alien4cloud by alien4cloud.
the class PluginManager method link.
/**
* Link the plugin against alien components that may need to use it.
*
* @param plugin The plugin to link.
* @param managedPlugin The managed plugin related to the plugin.
* @param componentDescriptors The map of component descriptors.
*/
private void link(Plugin plugin, ManagedPlugin managedPlugin, Map<String, PluginComponentDescriptor> componentDescriptors) {
// Global linking (rest-mapping for example)
for (IPluginLoadingCallback callback : SpringUtils.getBeansOfType(alienContext, IPluginLoadingCallback.class)) {
callback.onPluginLoaded(managedPlugin);
}
// Specific bean linking to bean types.
for (PluginLinker linker : linkers) {
Map<String, ?> instancesToLink = managedPlugin.getPluginContext().getBeansOfType(linker.linkedType);
for (Entry<String, ?> instanceToLink : instancesToLink.entrySet()) {
linker.linker.link(plugin.getId(), instanceToLink.getKey(), instanceToLink.getValue());
PluginComponentDescriptor componentDescriptor = componentDescriptors.get(instanceToLink.getKey());
if (componentDescriptor == null) {
componentDescriptor = new PluginComponentDescriptor();
componentDescriptor.setBeanName(instanceToLink.getKey());
componentDescriptor.setName(instanceToLink.getKey());
}
componentDescriptor.setType(linker.linkedType.getSimpleName());
}
}
// Add a default undefined type for all componentDescriptor that haven't been linked.
for (PluginComponentDescriptor componentDescriptor : componentDescriptors.values()) {
if (componentDescriptor.getType() == null) {
componentDescriptor.setType(UNKNOWN_PLUGIN_COMPONENT_TYPE);
}
}
}
use of alien4cloud.plugin.model.PluginComponentDescriptor 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