Interface PluginManager
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 Summary
Modifier and TypeMethodDescriptionvoidAdds a plugin to the manager's plugin collection.conflictsForPlugin(Plugin plugin) Gets a list of plugins that conflict with the specified plugin.getPluginConfigProxies(Collection<Plugin> plugins) Retrieves configuration proxies for multiple plugins.getPluginConfigProxy(Plugin plugin) Retrieves the configuration proxy for a plugin.Gets all plugins managed by this PluginManager.booleanisPluginEnabled(Plugin plugin) Checks if a plugin is currently enabled.voidLoads and initializes all core plugins.voidloadDefaultPluginConfiguration(Collection<Plugin> plugins) Loads default configuration values for a collection of plugins.loadPlugins(List<Class<?>> plugins, BiConsumer<Integer, Integer> onPluginLoaded) Loads plugins from a list of plugin classes.voidRemoves a plugin from the manager's plugin collection.voidsetPluginEnabled(Plugin plugin, boolean enabled) Sets the enabled state of a plugin.voidStarts all core plugins that are enabled.booleanstartPlugin(Plugin plugin) Starts a single plugin.voidStarts all enabled plugins.voidstartPlugins(Collection<Plugin> plugins) Starts a specific collection of plugins.booleanstopPlugin(Plugin plugin) Stops a single plugin.voidStops all currently running plugins.
-
Method Details
-
getPluginConfigProxy
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
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
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
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 PluginInstantiationExceptionLoads plugins from a list of plugin classes.- Parameters:
plugins- the list of plugin classes to loadonPluginLoaded- 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
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
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
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 modifyenabled- true to enable, false to disable
-
isPluginEnabled
Checks if a plugin is currently enabled.- Parameters:
plugin- the plugin to check- Returns:
- true if the plugin is enabled, false otherwise
-
add
Adds a plugin to the manager's plugin collection.- Parameters:
plugin- the plugin to add
-
remove
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
Loads and initializes all core plugins.- Throws:
IOException- if plugin classes cannot be readPluginInstantiationException- if a plugin fails to instantiate
-
conflictsForPlugin
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
-