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 Summary
Modifier and TypeMethodDescriptionvoid
addPluginStateListener
(PluginStateListener listener) boolean
deletePlugin
(String pluginId) Deletes a plugin.boolean
disablePlugin
(String pluginId) Disables a plugin from being loaded.boolean
enablePlugin
(String pluginId) Enables a plugin that has previously been disabled.getExtensionClasses
(Class<T> type) getExtensionClasses
(Class<T> type, String pluginId) getExtensionClasses
(String pluginId) getExtensionClassNames
(String pluginId) <T> List
<T> getExtensions
(Class<T> type) <T> List
<T> getExtensions
(Class<T> type, String pluginId) getExtensions
(String pluginId) Retrieves the plugin with this id, or null if the plugin does not exist.getPluginClassLoader
(String pluginId) Retrieves all plugins.getPlugins
(PluginState pluginState) Retrieves all plugins with this state.Gets the path of the folder where plugins are installed.Retrieves all resolved plugins (with resolved dependency).The runtime mode.Retrieves all started plugins.Returns the system version.Retrieves all unresolved plugins (with unresolved dependency).default boolean
Returnstrue
if the runtime mode isRuntimeMode.DEVELOPMENT
.default boolean
Returnstrue
if the runtime mode is notRuntimeMode.DEVELOPMENT
.loadPlugin
(Path pluginPath) Load a plugin.void
Load plugins.void
removePluginStateListener
(PluginStateListener listener) void
setSystemVersion
(String version) Set the system version.startPlugin
(String pluginId) Start the specified plugin and its dependencies.void
Start all active plugins.stopPlugin
(String pluginId) Stop the specified plugin and its dependencies.void
Stop all active plugins.boolean
unloadPlugin
(String pluginId) Unload a plugin.whichPlugin
(Class<?> clazz) Retrieves thePluginWrapper
that loaded the given class 'clazz'.
-
Method Details
-
getPlugins
List<PluginWrapper> getPlugins()Retrieves all plugins. -
getPlugins
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
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
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
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
Stop the specified plugin and its dependencies.- Returns:
- the plugin state
- Throws:
PluginRuntimeException
- if something goes wrong
-
unloadPlugin
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
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
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
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
-
getExtensionClasses
-
getExtensionClasses
-
getExtensionClasses
-
getExtensions
-
getExtensions
-
getExtensions
-
getExtensionClassNames
-
getExtensionFactory
ExtensionFactory getExtensionFactory() -
getRuntimeMode
RuntimeMode getRuntimeMode()The runtime mode. Must currently be either DEVELOPMENT or DEPLOYMENT. -
isDevelopment
default boolean isDevelopment()Returnstrue
if the runtime mode isRuntimeMode.DEVELOPMENT
. -
isNotDevelopment
default boolean isNotDevelopment()Returnstrue
if the runtime mode is notRuntimeMode.DEVELOPMENT
. -
whichPlugin
Retrieves thePluginWrapper
that loaded the given class 'clazz'. -
addPluginStateListener
-
removePluginStateListener
-
setSystemVersion
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()
-