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.
  • Constructor Details

  • Method Details

    • systemBundledStarted

      public void systemBundledStarted(org.osgi.framework.BundleContext context) throws Exception
      Specified by:
      systemBundledStarted in interface OsgiSystemBundleListener
      Throws:
      Exception
    • systemBundledStopped

      public void systemBundledStopped(org.osgi.framework.BundleContext context)
      Specified by:
      systemBundledStopped in interface OsgiSystemBundleListener
    • 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 interface PluginManager
      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

      public void deletePluginArtifactFromHome(Plugin plugin)
      Description copied from interface: PluginManager
      Deletes plugin artifact if present in the home directory.
      Specified by:
      deletePluginArtifactFromHome in interface PluginManager
      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 interface PluginManager
      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 interface PluginManager
      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

      public Plugin initializePlugin(Plugin plugin) throws PluginException
      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 interface PluginManager
      Parameters:
      plugin - plugin to initialize.
      Returns:
      plugin that was enabled or disabled.
      Throws:
      PluginException - if enabling or disabling the plugin fails.
    • uninstall

      public void uninstall(Plugin plugin) throws PluginException
      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 interface PluginManager
      Parameters:
      plugin - plugin to be uninstalled.
      Throws:
      PluginException - if the plugin is in use or uninstallation wasn't successful.
    • enablePlugin

      public Plugin enablePlugin(Plugin plugin) throws PluginException
      Description copied from interface: PluginManager
      Enables the previously installed plugin as well as its dependencies storing this state persistently.
      Specified by:
      enablePlugin in interface PluginManager
      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

      public Plugin disablePlugin(Plugin plugin) throws PluginException
      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 interface PluginManager
      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

      public Plugin disablePlugin(Plugin plugin, boolean storeState) throws PluginException
      Description copied from interface: PluginManager
      Disables the plugin and if required - stores this state persistently.
      Specified by:
      disablePlugin in interface PluginManager
      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

      public Plugin restartPlugin(Plugin plugin) throws PluginException
      Description copied from interface: PluginManager
      Disables and enables the plugin.
      Specified by:
      restartPlugin in interface PluginManager
      Parameters:
      plugin - plugin to be restarted.
      Returns:
      restarted plugin.
      Throws:
      PluginException - if there are problems during restart.
    • listPlugins

      public Collection<Plugin> listPlugins()
      Description copied from interface: PluginManager
      Returns a list consisting of all installed plugins.
      Specified by:
      listPlugins in interface PluginManager
      Returns:
      a list of installed plugins.
    • getPlugin

      public Plugin getPlugin(String key)
      Description copied from interface: PluginManager
      Get the installed plugins with passed key.
      Specified by:
      getPlugin in interface PluginManager
      Parameters:
      key - key of the plugin to get.
      Returns:
      installed plugin with given key.
    • purgePlugin

      public void purgePlugin(Plugin plugin) throws PluginException
      Description copied from interface: PluginManager
      Deletes all plugin data (db tables, resources, etc.) and disables the plugin.
      Specified by:
      purgePlugin in interface PluginManager
      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()