Class OsgiPluginManager
java.lang.Object
eu.rarogsoftware.rarog.platform.core.plugins.osgi.OsgiPluginManager
- All Implemented Interfaces:
PluginManager,OsgiSystemBundleListener
@Component
@DependsOn("MainPluginsSystemManager")
public class OsgiPluginManager
extends Object
implements PluginManager, OsgiSystemBundleListener
Plugin manager implementation that is used to manage OSGi based plugins.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static interface -
Constructor Summary
ConstructorsConstructorDescriptionOsgiPluginManager(PluggableFeatureRegistry featureRegistry, PluginsStateStore stateStore, HomeDirectoryHelper homeDirectoryHelper) -
Method Summary
Modifier and TypeMethodDescriptionvoiddeletePluginArtifactFromHome(Plugin plugin) Deletes plugin artifact if present in the home directory.disablePlugin(Plugin plugin) Disables the plugin and stores this state persistently - plugin won't be enabled after instance restart.disablePlugin(Plugin plugin, boolean storeState) Disables the plugin and if required - stores this state persistently.enablePlugin(Plugin plugin) Enables the previously installed plugin as well as its dependencies storing this state persistently.Get the installed plugins with passed key.initializePlugin(Plugin plugin) Checks the recently saved state and either disables or enables the plugin if installed.installPlugin(PluginArtifact pluginArtifact, boolean storeState) Installs plugin in the system and if required stores the state if the installation went correctly.Returns a list consisting of all installed plugins.voidpurgePlugin(Plugin plugin) Deletes all plugin data (db tables, resources, etc.) and disables the plugin.restartPlugin(Plugin plugin) Disables and enables the plugin.savePluginArtifactToHome(PluginArtifact artifact) Saves an artifact in 'home'/plugins directory and returns an object representing the saved artifact.voidvoidsystemBundledStarted(org.osgi.framework.BundleContext context) voidsystemBundledStopped(org.osgi.framework.BundleContext context) voidRemoves the plugin from the system and removes the artifact from home if there was any.voidvalidatePluginArtifact(PluginArtifact pluginArtifact) Validates correctness of the passed artifact.
-
Constructor Details
-
OsgiPluginManager
public OsgiPluginManager(PluggableFeatureRegistry featureRegistry, PluginsStateStore stateStore, HomeDirectoryHelper homeDirectoryHelper)
-
-
Method Details
-
systemBundledStarted
- Specified by:
systemBundledStartedin interfaceOsgiSystemBundleListener- Throws:
Exception
-
systemBundledStopped
public void systemBundledStopped(org.osgi.framework.BundleContext context) - Specified by:
systemBundledStoppedin interfaceOsgiSystemBundleListener
-
savePluginArtifactToHome
public PluginArtifact savePluginArtifactToHome(PluginArtifact artifact) throws PluginException, IOException Description copied from interface:PluginManagerSaves an artifact in 'home'/plugins directory and returns an object representing the saved artifact.- Specified by:
savePluginArtifactToHomein interfacePluginManager- Parameters:
artifact- artifact to be saved in home directory.- Returns:
- artifact pointing at the resource in home directory.
- Throws:
PluginException- if the artifact is not a valid plugin.IOException- if something goes wrong when saving the artifact in the filesystem.
-
deletePluginArtifactFromHome
Description copied from interface:PluginManagerDeletes plugin artifact if present in the home directory.- Specified by:
deletePluginArtifactFromHomein interfacePluginManager- Parameters:
plugin- plugin which artifact should be deleted.
-
validatePluginArtifact
public void validatePluginArtifact(PluginArtifact pluginArtifact) throws PluginException, IOException Description copied from interface:PluginManagerValidates correctness of the passed artifact.- Specified by:
validatePluginArtifactin interfacePluginManager- Parameters:
pluginArtifact- artifact to be validated.- Throws:
PluginException- if passed artifact is not a valid plugin.IOException- if there are problems accessing the artifact's resource.
-
installPlugin
public Plugin installPlugin(PluginArtifact pluginArtifact, boolean storeState) throws IOException, PluginException Description copied from interface:PluginManagerInstalls plugin in the system and if required stores the state if the installation went correctly. Doesn't save the plugin artifact in home directory.- Specified by:
installPluginin interfacePluginManager- Parameters:
pluginArtifact- artifact to install the plugin from.storeState- should the state be stored after installation.- Returns:
Pluginreferencing installed plugin.- Throws:
IOException- if there are problems accessing the artifact's resource.PluginException- if the artifact is invalid or the installation fails.
-
initializePlugin
Description copied from interface:PluginManagerChecks the recently saved state and either disables or enables the plugin if installed. Useful e.g. on instance startup.- Specified by:
initializePluginin interfacePluginManager- Parameters:
plugin- plugin to initialize.- Returns:
- plugin that was enabled or disabled.
- Throws:
PluginException- if enabling or disabling the plugin fails.
-
uninstall
Description copied from interface:PluginManagerRemoves the plugin from the system and removes the artifact from home if there was any.- Specified by:
uninstallin interfacePluginManager- Parameters:
plugin- plugin to be uninstalled.- Throws:
PluginException- if the plugin is in use or uninstallation wasn't successful.
-
enablePlugin
Description copied from interface:PluginManagerEnables the previously installed plugin as well as its dependencies storing this state persistently.- Specified by:
enablePluginin interfacePluginManager- Parameters:
plugin- plugin to be enabled.- Returns:
- the enabled plugin.
- Throws:
PluginException- if plugin is not installed or there are problems enabling the plugin or its dependencies.
-
disablePlugin
Description copied from interface:PluginManagerDisables the plugin and stores this state persistently - plugin won't be enabled after instance restart.- Specified by:
disablePluginin interfacePluginManager- Parameters:
plugin- plugin to be disabled.- Returns:
- disabled plugin.
- Throws:
PluginException- if the plugin is not installed or there are problems disabling the plugin.
-
disablePlugin
Description copied from interface:PluginManagerDisables the plugin and if required - stores this state persistently.- Specified by:
disablePluginin interfacePluginManager- Parameters:
plugin- plugin to be disabled.storeState- should the store be saved after disabling the plugin.- Returns:
- disabled plugin.
- Throws:
PluginException- if the plugin is not installed or there are problems disabling the plugin.
-
restartPlugin
Description copied from interface:PluginManagerDisables and enables the plugin.- Specified by:
restartPluginin interfacePluginManager- Parameters:
plugin- plugin to be restarted.- Returns:
- restarted plugin.
- Throws:
PluginException- if there are problems during restart.
-
listPlugins
Description copied from interface:PluginManagerReturns a list consisting of all installed plugins.- Specified by:
listPluginsin interfacePluginManager- Returns:
- a list of installed plugins.
-
getPlugin
Description copied from interface:PluginManagerGet the installed plugins with passed key.- Specified by:
getPluginin interfacePluginManager- Parameters:
key- key of the plugin to get.- Returns:
- installed plugin with given key.
-
purgePlugin
Description copied from interface:PluginManagerDeletes all plugin data (db tables, resources, etc.) and disables the plugin.- Specified by:
purgePluginin interfacePluginManager- Parameters:
plugin- plugin to be purged.- Throws:
PluginException- if the plugin is not installed or there were problems purging the plugin.
-
shutdownPlugins
@PreDestroy public void shutdownPlugins()
-