Package ai.djl.serving.plugins
Class FolderScanPluginManager
java.lang.Object
ai.djl.serving.plugins.FolderScanPluginManager
- All Implemented Interfaces:
PluginManager
The
PluginManager
is responsible to load and manage plugins from the file system.
The Plugin Folder configuration is received from the ConfigManager
and usually
defaults to {workpath}/plugins. The plugins uses Java's SPI and have to implement interfaces from
serving-api.
-
Constructor Summary
ConstructorDescriptionFolderScanPluginManager
(ConfigManager configManager) Constructs aPluginManager
instance. -
Method Summary
Modifier and TypeMethodDescription<T> Set<T>
findImplementations
(Class<T> pluginInterface) returns a set of plug-in components implementing the specific service interface.protected void
initializeComponent
(ClassLoader ucl, PluginMetaData plugin, String handlerClassName) protected void
injectDependenciesIntoComponent
(Object component) Initializes a plugin by calling known setters to inject managers and other dependant plugins into the plugins.List all plugins.void
loadPlugins
(boolean failOnInit) Loads all plugins from the plugin folder and register them.
-
Constructor Details
-
FolderScanPluginManager
Constructs aPluginManager
instance.- Parameters:
configManager
- a instance of the configManager to lookup configuration like plugin-folder.
-
-
Method Details
-
loadPlugins
Loads all plugins from the plugin folder and register them.- Parameters:
failOnInit
- throw exception if failed to initialize the plugin- Throws:
IOException
- when error during IO operation occurs.
-
initializeComponent
protected void initializeComponent(ClassLoader ucl, PluginMetaData plugin, String handlerClassName) throws ReflectiveOperationException, IntrospectionException -
injectDependenciesIntoComponent
protected void injectDependenciesIntoComponent(Object component) throws IntrospectionException, ReflectiveOperationException, InvocationTargetException Initializes a plugin by calling known setters to inject managers and other dependant plugins into the plugins.- Parameters:
component
- the component to get initialized- Throws:
IntrospectionException
- when initialization fails.InvocationTargetException
- when initialization fails.ReflectiveOperationException
- when initialization fails.
-
findImplementations
returns a set of plug-in components implementing the specific service interface.only active plug-ins are returned which are fully initialised at this point.
Set<RequestHandler> allActiveRequestHandler=findImplementations(RequestHandler.class)
- Specified by:
findImplementations
in interfacePluginManager
- Type Parameters:
T
- generic type of service interface- Parameters:
pluginInterface
- the specific service interface- Returns:
- a set of all plugin components implementing this service interface
-
listPlugins
List all plugins.- Specified by:
listPlugins
in interfacePluginManager
- Returns:
- list of all plugins.
-