Interface PluginManager

All Known Implementing Classes:
OsgiPluginManager

public interface PluginManager
Interface used to manage plugins and their artifacts.
  • Method Details

    • savePluginArtifactToHome

      PluginArtifact savePluginArtifactToHome(PluginArtifact artifact) throws PluginException, IOException
      Saves an artifact in 'home'/plugins directory and returns an object representing the saved artifact.
      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

      void deletePluginArtifactFromHome(Plugin plugin)
      Deletes plugin artifact if present in the home directory.
      Parameters:
      plugin - plugin which artifact should be deleted.
    • validatePluginArtifact

      void validatePluginArtifact(PluginArtifact pluginArtifact) throws PluginException, IOException
      Validates correctness of the passed artifact.
      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

      Plugin installPlugin(PluginArtifact artifact, boolean storeState) throws IOException, PluginException
      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.
      Parameters:
      artifact - 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

      Plugin initializePlugin(Plugin plugin) throws PluginException
      Checks the recently saved state and either disables or enables the plugin if installed. Useful e.g. on instance startup.
      Parameters:
      plugin - plugin to initialize.
      Returns:
      plugin that was enabled or disabled.
      Throws:
      PluginException - if enabling or disabling the plugin fails.
    • uninstall

      void uninstall(Plugin plugin) throws PluginException
      Removes the plugin from the system and removes the artifact from home if there was any.
      Parameters:
      plugin - plugin to be uninstalled.
      Throws:
      PluginException - if the plugin is in use or uninstallation wasn't successful.
    • enablePlugin

      Plugin enablePlugin(Plugin plugin) throws PluginException
      Enables the previously installed plugin as well as its dependencies storing this state persistently.
      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.
    • restartPlugin

      Plugin restartPlugin(Plugin plugin) throws PluginException
      Disables and enables the plugin.
      Parameters:
      plugin - plugin to be restarted.
      Returns:
      restarted plugin.
      Throws:
      PluginException - if there are problems during restart.
    • disablePlugin

      Plugin disablePlugin(Plugin plugin) throws PluginException
      Disables the plugin and stores this state persistently - plugin won't be enabled after instance restart.
      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

      Plugin disablePlugin(Plugin plugin, boolean storeState) throws PluginException
      Disables the plugin and if required - stores this state persistently.
      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.
    • listPlugins

      Collection<Plugin> listPlugins()
      Returns a list consisting of all installed plugins.
      Returns:
      a list of installed plugins.
    • getPlugin

      Plugin getPlugin(String key)
      Get the installed plugins with passed key.
      Parameters:
      key - key of the plugin to get.
      Returns:
      installed plugin with given key.
    • purgePlugin

      void purgePlugin(Plugin plugin) throws PluginException
      Deletes all plugin data (db tables, resources, etc.) and disables the plugin.
      Parameters:
      plugin - plugin to be purged.
      Throws:
      PluginException - if the plugin is not installed or there were problems purging the plugin.