Package org.pf4j

Interface PluginManager

All Known Implementing Classes:
AbstractPluginManager, DefaultPluginManager, JarPluginManager, ZipPluginManager

public interface PluginManager
Provides the functionality for plugin management such as load, start and stop the plugins.
  • Method Details

    • getPlugins

      List<PluginWrapper> getPlugins()
      Retrieves all plugins.
    • getPlugins

      List<PluginWrapper> getPlugins(PluginState pluginState)
      Retrieves all plugins with this state.
    • getResolvedPlugins

      List<PluginWrapper> getResolvedPlugins()
      Retrieves all resolved plugins (with resolved dependency).
    • getUnresolvedPlugins

      List<PluginWrapper> getUnresolvedPlugins()
      Retrieves all unresolved plugins (with unresolved dependency).
    • getStartedPlugins

      List<PluginWrapper> getStartedPlugins()
      Retrieves all started plugins.
    • getPlugin

      PluginWrapper getPlugin(String pluginId)
      Retrieves the plugin with this id, or null if the plugin does not exist.
      Parameters:
      pluginId - the unique plugin identifier, specified in its metadata
      Returns:
      A PluginWrapper object for this plugin, or null if it does not exist.
    • loadPlugins

      void loadPlugins()
      Load plugins.
    • loadPlugin

      String loadPlugin(Path pluginPath)
      Load a plugin.
      Parameters:
      pluginPath - the plugin location
      Returns:
      the pluginId of the installed plugin as specified in its metadata
      Throws:
      PluginRuntimeException - if something goes wrong
    • startPlugins

      void startPlugins()
      Start all active plugins.
    • startPlugin

      PluginState startPlugin(String pluginId)
      Start the specified plugin and its dependencies.
      Returns:
      the plugin state
      Throws:
      PluginRuntimeException - if something goes wrong
    • stopPlugins

      void stopPlugins()
      Stop all active plugins.
    • stopPlugin

      PluginState stopPlugin(String pluginId)
      Stop the specified plugin and its dependencies.
      Returns:
      the plugin state
      Throws:
      PluginRuntimeException - if something goes wrong
    • unloadPlugin

      boolean unloadPlugin(String pluginId)
      Unload a plugin.
      Parameters:
      pluginId - the unique plugin identifier, specified in its metadata
      Returns:
      true if the plugin was unloaded
      Throws:
      PluginRuntimeException - if something goes wrong
    • disablePlugin

      boolean disablePlugin(String pluginId)
      Disables a plugin from being loaded.
      Parameters:
      pluginId - the unique plugin identifier, specified in its metadata
      Returns:
      true if plugin is disabled
      Throws:
      PluginRuntimeException - if something goes wrong
    • enablePlugin

      boolean enablePlugin(String pluginId)
      Enables a plugin that has previously been disabled.
      Parameters:
      pluginId - the unique plugin identifier, specified in its metadata
      Returns:
      true if plugin is enabled
      Throws:
      PluginRuntimeException - if something goes wrong
    • deletePlugin

      boolean deletePlugin(String pluginId)
      Deletes a plugin.
      Parameters:
      pluginId - the unique plugin identifier, specified in its metadata
      Returns:
      true if the plugin was deleted
      Throws:
      PluginRuntimeException - if something goes wrong
    • getPluginClassLoader

      ClassLoader getPluginClassLoader(String pluginId)
    • getExtensionClasses

      List<Class<?>> getExtensionClasses(String pluginId)
    • getExtensionClasses

      <T> List<Class<? extends T>> getExtensionClasses(Class<T> type)
    • getExtensionClasses

      <T> List<Class<? extends T>> getExtensionClasses(Class<T> type, String pluginId)
    • getExtensions

      <T> List<T> getExtensions(Class<T> type)
    • getExtensions

      <T> List<T> getExtensions(Class<T> type, String pluginId)
    • getExtensions

      List getExtensions(String pluginId)
    • getExtensionClassNames

      Set<String> getExtensionClassNames(String pluginId)
    • getExtensionFactory

      ExtensionFactory getExtensionFactory()
    • getRuntimeMode

      RuntimeMode getRuntimeMode()
      The runtime mode. Must currently be either DEVELOPMENT or DEPLOYMENT.
    • isDevelopment

      default boolean isDevelopment()
      Returns true if the runtime mode is RuntimeMode.DEVELOPMENT.
    • isNotDevelopment

      default boolean isNotDevelopment()
      Returns true if the runtime mode is not RuntimeMode.DEVELOPMENT.
    • whichPlugin

      PluginWrapper whichPlugin(Class<?> clazz)
      Retrieves the PluginWrapper that loaded the given class 'clazz'.
    • addPluginStateListener

      void addPluginStateListener(PluginStateListener listener)
    • removePluginStateListener

      void removePluginStateListener(PluginStateListener listener)
    • setSystemVersion

      void setSystemVersion(String version)
      Set the system version. This is used to compare against the plugin requires attribute. The default system version is 0.0.0 which disables all version checking.
      Parameters:
      version -
    • getSystemVersion

      String getSystemVersion()
      Returns the system version.
      Returns:
      the system version
    • getPluginsRoot

      Path getPluginsRoot()
      Gets the path of the folder where plugins are installed.
      Returns:
      Path of plugins root
    • getVersionManager

      VersionManager getVersionManager()