Class PluginManager

java.lang.Object
is.galia.plugin.PluginManager

public final class PluginManager extends Object

Provides programmatic access to plugins, including listing, installing, and removing them.

N.B.: There are two types of what are referred to by this class as plugins: plugin directories and plugin implementation classes. The former are expected to have the following name format: <plugin-name>-<version>.

  • Method Details

    • getPluginBackupDirs

      public static Set<Path> getPluginBackupDirs(String pluginName) throws IOException
      Similar to getPluginDir(String), but includes plugin backup directories.
      Throws:
      IOException
    • getPluginDir

      public static Path getPluginDir(String pluginName) throws IOException
      Parameters:
      pluginName - Plugin name.
      Returns:
      The directory of the active plugin with the given name. Backup directories are not considered.
      Throws:
      IOException
      See Also:
    • getPluginDirNames

      public static Set<String> getPluginDirNames() throws IOException
      Returns:
      Names of all non-backup plugin directories, excluding their version suffix,
      Throws:
      IOException
    • getPluginDirs

      public static Set<Path> getPluginDirs() throws IOException
      Returns:
      All plugin directories, excluding backups.
      Throws:
      IOException
    • getPlugins

      public static Set<Plugin> getPlugins()
      N.B.: Do not use any of these instances. They may not have been initialized properly. Obtain them instead from a relevant factory class.
      Returns:
      All installed instances.
    • getPluginsDir

      public static Path getPluginsDir()
      Returns:
      Root plugins directory.
    • getInstaller

      public static PluginInstaller getInstaller()
      Returns:
      Shared instance.
    • getRemover

      public static PluginRemover getRemover()
      Returns:
      Shared instance.
    • getUpdater

      public static PluginUpdater getUpdater()
      Returns:
      Shared instance.
    • getVersion

      public static SoftwareVersion getVersion(String pluginName) throws IOException, PluginNotInstalledException
      Parses the name of the version from the directory of the installed plugin with the given name.
      Parameters:
      pluginName - Name of an installed plugin.
      Returns:
      The version of the installed plugin.
      Throws:
      IOException - if there are any file access issues.
      PluginNotInstalledException - if there is no installed plugin with the given name.
    • isPluginInstalled

      public static boolean isPluginInstalled(String pluginName) throws IOException
      Throws:
      IOException
    • setRepositoryBaseURI

      public static void setRepositoryBaseURI(Reference baseURI)
      Overrides the artifact repository base URI used for plugin installation and updating. This is used in testing.
      Parameters:
      baseURI - New base URI.
    • setPluginsDir

      public static void setPluginsDir(Path pluginsDir)
      Overrides the default plugin path.
      Parameters:
      pluginsDir - New root plugin directory.