Interface PluginManager
public interface PluginManager
Manages loading and retrieving plugins.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddPluginPath(Path path) Add a path to scan for plugins.voidaddToClasspath(Object plugin, Path file) Add a JAR file to a plugin's classpath at runtime.fromInstance(Object instance) Get a plugin container from a plugin instance.Get a plugin by its ID.Get all loaded plugins.Get the plugin directory where plugins are loaded from.booleanCheck if a plugin is loaded.
-
Method Details
-
getPlugin
Get a plugin by its ID.- Parameters:
id- the plugin ID- Returns:
- the plugin container, or empty if not found
-
fromInstance
Get a plugin container from a plugin instance.This is useful when you have a reference to a plugin's main class instance and need to get its container metadata.
- Parameters:
instance- the plugin instance- Returns:
- the plugin container, or empty if not found
-
getPlugins
Get all loaded plugins.- Returns:
- an unmodifiable collection of all plugins
-
isLoaded
Check if a plugin is loaded.- Parameters:
id- the plugin ID- Returns:
- true if the plugin is loaded
-
getPluginsDirectory
Get the plugin directory where plugins are loaded from.- Returns:
- the plugins directory
-
addPluginPath
Add a path to scan for plugins.- Parameters:
path- the path to add
-
addToClasspath
Add a JAR file to a plugin's classpath at runtime.This allows plugins to dynamically load additional dependencies after initialization, such as database drivers or other libraries.
- Parameters:
plugin- the plugin instance requesting the classpath additionfile- the path to the JAR file to add
-