Interface PluginManager


public interface PluginManager
Central manager interface for plugin lifecycle and configuration.

The PluginManager handles all aspects of plugin management including:

  • Loading and instantiating plugins
  • Starting and stopping plugins
  • Managing plugin configurations
  • Tracking plugin enabled states
  • Handling plugin conflicts

This interface is typically injected into plugins or services that need to interact with other plugins or the plugin system.

Example usage:


 @Inject
 private PluginManager pluginManager;

 public void enableRelatedPlugin() {
     for (Plugin plugin : pluginManager.getPlugins()) {
         if (plugin.getName().equals("Related Plugin")) {
             pluginManager.startPlugin(plugin);
             break;
         }
     }
 }
 

See Also:
  • Method Details

    • getPluginConfigProxy

      Config getPluginConfigProxy(Plugin plugin)
      Retrieves the configuration proxy for a plugin.

      The configuration proxy is a dynamic implementation of the plugin's Config interface that automatically reads and writes values to storage.

      Parameters:
      plugin - the plugin to get the configuration for
      Returns:
      the configuration proxy, or null if the plugin has no configuration
    • getPluginConfigProxies

      List<Config> getPluginConfigProxies(Collection<Plugin> plugins)
      Retrieves configuration proxies for multiple plugins.
      Parameters:
      plugins - the collection of plugins to get configurations for
      Returns:
      a list of configuration proxies for plugins that have configurations
    • loadDefaultPluginConfiguration

      void loadDefaultPluginConfiguration(Collection<Plugin> plugins)
      Loads default configuration values for a collection of plugins.

      This sets all configuration items to their default values as defined in the Config interface default methods.

      Parameters:
      plugins - the plugins to load default configuration for
    • startCorePlugins

      void startCorePlugins()
      Starts all core plugins that are enabled.

      Core plugins are bundled with the Storm client and are loaded from the internal classpath.

    • startPlugins

      void startPlugins()
      Starts all enabled plugins.

      This method starts all plugins that are marked as enabled in the plugin configuration.

    • startPlugins

      void startPlugins(Collection<Plugin> plugins)
      Starts a specific collection of plugins.
      Parameters:
      plugins - the plugins to start
    • stopPlugins

      void stopPlugins()
      Stops all currently running plugins.
    • loadPlugins

      List<Plugin> loadPlugins(List<Class<?>> plugins, BiConsumer<Integer,Integer> onPluginLoaded) throws PluginInstantiationException
      Loads plugins from a list of plugin classes.
      Parameters:
      plugins - the list of plugin classes to load
      onPluginLoaded - callback invoked after each plugin loads, with current and total count
      Returns:
      the list of successfully loaded plugin instances
      Throws:
      PluginInstantiationException - if a plugin fails to instantiate
    • startPlugin

      boolean startPlugin(Plugin plugin) throws PluginInstantiationException
      Starts a single plugin.

      This calls the plugin's Plugin.startUp() method and registers the plugin with the event bus.

      Parameters:
      plugin - the plugin to start
      Returns:
      true if the plugin started successfully, false otherwise
      Throws:
      PluginInstantiationException - if the plugin fails to start
    • stopPlugin

      boolean stopPlugin(Plugin plugin) throws PluginInstantiationException
      Stops a single plugin.

      This calls the plugin's Plugin.shutDown() method and unregisters the plugin from the event bus.

      Parameters:
      plugin - the plugin to stop
      Returns:
      true if the plugin stopped successfully, false otherwise
      Throws:
      PluginInstantiationException - if the plugin fails to stop
    • setPluginEnabled

      void setPluginEnabled(Plugin plugin, boolean enabled)
      Sets the enabled state of a plugin.

      This persists the enabled state to configuration, so it will be remembered across client restarts.

      Parameters:
      plugin - the plugin to modify
      enabled - true to enable, false to disable
    • isPluginEnabled

      boolean isPluginEnabled(Plugin plugin)
      Checks if a plugin is currently enabled.
      Parameters:
      plugin - the plugin to check
      Returns:
      true if the plugin is enabled, false otherwise
    • add

      void add(Plugin plugin)
      Adds a plugin to the manager's plugin collection.
      Parameters:
      plugin - the plugin to add
    • remove

      void remove(Plugin plugin)
      Removes a plugin from the manager's plugin collection.
      Parameters:
      plugin - the plugin to remove
    • getPlugins

      Collection<Plugin> getPlugins()
      Gets all plugins managed by this PluginManager.
      Returns:
      a collection of all loaded plugins
    • loadCorePlugins

      void loadCorePlugins() throws IOException, PluginInstantiationException
      Loads and initializes all core plugins.
      Throws:
      IOException - if plugin classes cannot be read
      PluginInstantiationException - if a plugin fails to instantiate
    • conflictsForPlugin

      List<Plugin> conflictsForPlugin(Plugin plugin)
      Gets a list of plugins that conflict with the specified plugin.

      Conflicts are determined by the PluginDescriptor.conflicts() annotation.

      Parameters:
      plugin - the plugin to check for conflicts
      Returns:
      a list of plugins that conflict with the specified plugin