public class DefaultPluginManager extends Object implements PluginManager
Modifier and Type | Field and Description |
---|---|
protected AnnotationProcessor |
annotationProcessor |
protected PluginContext |
context |
protected DependencyResolver |
dependencyResolver |
Constructor and Description |
---|
DefaultPluginManager(PluginContext context,
AnnotationProcessor annotationProcessor,
DependencyResolver dependencyResolver)
Ideally not for public usage.
|
Modifier and Type | Method and Description |
---|---|
protected Object |
create(Class<?> refClass) |
Collection<PluginRef> |
getAllPlugins()
Return the complete list of all the plugins currently registered
|
<T> T |
getPlugin(Class<T> pluginClass)
Return an instance of the plugin matching the given type
given type
|
<T> T |
getPlugin(String name)
Return an instance of the plugin that is registered with the given name
|
Collection<Object> |
loadPlugins(PluginSource source)
Load a set of plugin retrieved from the give
PluginSource ,
instantiating the objects, resolving any dependency and registering them
in the context |
<T> void |
register(String name,
T plugin)
Register a plugin in the context with the given name
|
<T> void |
register(T plugin)
Register a plugin in the context
|
<T> T |
removePlugin(String name)
Remove a plugin with the given name from the context
|
<T> T |
removePlugin(T plugin)
Remove a plugin from the context
|
protected final PluginContext context
protected final AnnotationProcessor annotationProcessor
protected final DependencyResolver dependencyResolver
public DefaultPluginManager(PluginContext context, AnnotationProcessor annotationProcessor, DependencyResolver dependencyResolver)
PluginManagers.defaultPluginManager()
instead for a fully
configured DefaultPluginManager
context
- the PluginContext
to useannotationProcessor
- the AnnotationProcessor
to usedependencyResolver
- the DependencyResolver
to usepublic <T> void register(T plugin)
PluginManager
register
in interface PluginManager
T
- the inferred type of the pluginplugin
- the plugin object to registerpublic <T> void register(String name, T plugin)
PluginManager
register
in interface PluginManager
T
- the inferred type of the pluginname
- the name to associate with the pluginplugin
- the plugin object to registerpublic <T> T getPlugin(String name)
PluginManager
getPlugin
in interface PluginManager
T
- the inferred type of the pluginname
- the name of the pluginnull
if none existspublic <T> T getPlugin(Class<T> pluginClass)
PluginManager
getPlugin
in interface PluginManager
T
- the inferred type of the pluginpluginClass
- type the plugin must match; can be an interface or superclass. Cannot be null
null
if none existspublic Collection<PluginRef> getAllPlugins()
PluginManager
getAllPlugins
in interface PluginManager
Collection
of all the pluginspublic <T> T removePlugin(String name)
PluginManager
removePlugin
in interface PluginManager
T
- the inferred type of the pluginname
- the name associated with the pluginnull
if none is existspublic <T> T removePlugin(T plugin)
PluginManager
removePlugin
in interface PluginManager
T
- the inferred type of the pluginplugin
- the plugin instance to removenull
if none is existspublic Collection<Object> loadPlugins(PluginSource source) throws Exception
PluginManager
PluginSource
,
instantiating the objects, resolving any dependency and registering them
in the contextloadPlugins
in interface PluginManager
source
- the PluginSource
to use for loadingnull
Exception
- an exception that occurred during loading, see PluginSource.load()
Copyright © 2017–2018 PlugFace. All rights reserved.