Package dev.siea.jonion.manager
Class DefaultPluginManager
java.lang.Object
dev.siea.jonion.manager.AbstractPluginManager
dev.siea.jonion.manager.DefaultPluginManager
- All Implemented Interfaces:
PluginManager
Default implementation of
AbstractPluginManager that adds start/stop lifecycle
support for SimplePlugin instances.
After plugins are loaded (by the parent class), start() invokes
SimplePlugin.start() on each loaded plugin. stop() invokes
SimplePlugin.stop() on each loaded plugin and then unloads
all plugins. Only wrappers in PluginState.LOADED state are started or stopped;
failures are logged and the wrapper's state is set to PluginState.FAILED.
Note: This manager assumes all loaded plugins are instances of
SimplePlugin. Plugins that extend Plugin but not
SimplePlugin will throw ClassCastException when started or stopped.
- See Also:
-
Field Summary
Fields inherited from class dev.siea.jonion.manager.AbstractPluginManager
logger -
Constructor Summary
ConstructorsConstructorDescriptionCreates a manager that scans the defaultpluginsdirectory with the default YAML descriptor finder.DefaultPluginManager(Path directory) Creates a manager that scans the given directory with the default YAML descriptor finder.DefaultPluginManager(Path directory, PluginDescriptorFinder descriptorFinder) Creates a manager with a custom descriptor finder and default YAML configuration finder. -
Method Summary
Modifier and TypeMethodDescriptionvoidstart()Starts all loaded plugins by callingSimplePlugin.start()on each.voidstop()Stops all loaded plugins by callingSimplePlugin.stop()on each, thenunloadsevery plugin.Methods inherited from class dev.siea.jonion.manager.AbstractPluginManager
createPluginWrapperFromPath, createPluginWrappers, getPlugin, getPlugins, getPlugins, reloadPlugins, unloadPlugin, unloadPlugins
-
Constructor Details
-
DefaultPluginManager
public DefaultPluginManager()Creates a manager that scans the defaultpluginsdirectory with the default YAML descriptor finder. -
DefaultPluginManager
Creates a manager that scans the given directory with the default YAML descriptor finder.- Parameters:
directory- the path to the plugin directory (created if it does not exist)
-
DefaultPluginManager
Creates a manager with a custom descriptor finder and default YAML configuration finder.- Parameters:
directory- the path to the plugin directory (created if it does not exist)descriptorFinder- the finder used to read plugin descriptors from JARs
-
-
Method Details
-
start
public void start()Starts all loaded plugins by callingSimplePlugin.start()on each. Only wrappers inPluginState.LOADEDare started. On failure the wrapper is set toPluginState.FAILEDand the error is logged. Logs a summary of how many plugins started successfully and how many failed. -
stop
public void stop()Stops all loaded plugins by callingSimplePlugin.stop()on each, thenunloadsevery plugin. Only wrappers inPluginState.LOADEDare stopped; failures are logged and the wrapper is set toPluginState.FAILED.
-