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 TypeMethodDescriptionvoid
deletePluginArtifactFromHome
(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.void
purgePlugin
(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.void
void
systemBundledStarted
(org.osgi.framework.BundleContext context) void
systemBundledStopped
(org.osgi.framework.BundleContext context) void
Removes the plugin from the system and removes the artifact from home if there was any.void
validatePluginArtifact
(PluginArtifact pluginArtifact) Validates correctness of the passed artifact.
-
Constructor Details
-
OsgiPluginManager
public OsgiPluginManager(PluggableFeatureRegistry featureRegistry, PluginsStateStore stateStore, HomeDirectoryHelper homeDirectoryHelper)
-
-
Method Details
-
systemBundledStarted
- Specified by:
systemBundledStarted
in interfaceOsgiSystemBundleListener
- Throws:
Exception
-
systemBundledStopped
public void systemBundledStopped(org.osgi.framework.BundleContext context) - Specified by:
systemBundledStopped
in interfaceOsgiSystemBundleListener
-
savePluginArtifactToHome
public PluginArtifact savePluginArtifactToHome(PluginArtifact artifact) throws PluginException, IOException Description copied from interface:PluginManager
Saves an artifact in 'home'/plugins directory and returns an object representing the saved artifact.- Specified by:
savePluginArtifactToHome
in 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:PluginManager
Deletes plugin artifact if present in the home directory.- Specified by:
deletePluginArtifactFromHome
in interfacePluginManager
- Parameters:
plugin
- plugin which artifact should be deleted.
-
validatePluginArtifact
public void validatePluginArtifact(PluginArtifact pluginArtifact) throws PluginException, IOException Description copied from interface:PluginManager
Validates correctness of the passed artifact.- Specified by:
validatePluginArtifact
in 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:PluginManager
Installs 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:
installPlugin
in interfacePluginManager
- Parameters:
pluginArtifact
- artifact to install the plugin from.storeState
- should the state be stored after installation.- Returns:
Plugin
referencing 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:PluginManager
Checks the recently saved state and either disables or enables the plugin if installed. Useful e.g. on instance startup.- Specified by:
initializePlugin
in 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:PluginManager
Removes the plugin from the system and removes the artifact from home if there was any.- Specified by:
uninstall
in 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:PluginManager
Enables the previously installed plugin as well as its dependencies storing this state persistently.- Specified by:
enablePlugin
in 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:PluginManager
Disables the plugin and stores this state persistently - plugin won't be enabled after instance restart.- Specified by:
disablePlugin
in 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:PluginManager
Disables the plugin and if required - stores this state persistently.- Specified by:
disablePlugin
in 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:PluginManager
Disables and enables the plugin.- Specified by:
restartPlugin
in interfacePluginManager
- Parameters:
plugin
- plugin to be restarted.- Returns:
- restarted plugin.
- Throws:
PluginException
- if there are problems during restart.
-
listPlugins
Description copied from interface:PluginManager
Returns a list consisting of all installed plugins.- Specified by:
listPlugins
in interfacePluginManager
- Returns:
- a list of installed plugins.
-
getPlugin
Description copied from interface:PluginManager
Get the installed plugins with passed key.- Specified by:
getPlugin
in interfacePluginManager
- Parameters:
key
- key of the plugin to get.- Returns:
- installed plugin with given key.
-
purgePlugin
Description copied from interface:PluginManager
Deletes all plugin data (db tables, resources, etc.) and disables the plugin.- Specified by:
purgePlugin
in 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()
-