Class PluginManagerImpl
- All Implemented Interfaces:
PluginManager
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.processmining.framework.plugin.PluginManager
PluginManager.PluginManagerListener
-
Field Summary
Fields inherited from interface org.processmining.framework.plugin.PluginManager
CLASS_EXTENSION, FILE_PROTOCOL, JAR_EXTENSION, MCR_EXTENSION
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a listener to the plugin manager.find
(Class<? extends Annotation> annotation, Class<?>[] resultTypes, Class<? extends PluginContext> contextType, boolean totalMatch, boolean orderedParameters, boolean mustBeUserVisible, Class<?>... parameters) This method retuns a collection ofPair
s ofInteger
andPluginParameterBinding
objects, such that:find
(Class<? extends Annotation> annotation, Class<?> resultType, Class<? extends PluginContext> contextType, boolean totalMatch, boolean orderedParameters, boolean mustBeUserVisible, Class<?>... parameters) This method retuns a collection ofPair
s ofInteger
andPluginParameterBinding
objects, such that:protected void
protected void
firePluginAdded
(PluginDescriptor plugin, Collection<Class<?>> types) Returns all plugin descriptorsgetAllPlugins
(boolean mustBeVisible) Returns all plugin descriptors known to the plugin manager.static PluginManager
getKnownClassesAnnotatedWith
(Class<? extends Annotation> annotationType) Returns all known classes annotated with a certain annotationType.Returns the set of types that is known to the plugin manager.Returns a PluginDescriptor of which the toString() of its id equals the given id.Returns a PluginDescriptor with the given id.getPluginsAcceptingAtLeast
(Class<? extends PluginContext> contextType, boolean mustBeUserVisible, Class<?>... parameters) Returns PluginParameterBindings, which can be invoked in the given context on the given parameter types.getPluginsAcceptingInAnyOrder
(Class<? extends PluginContext> contextType, boolean mustBeUserVisible, Class<?>... parameters) Returns executable PluginParameterBindings, which can be invoked in the given context on the given parameter types.getPluginsAcceptingOrdered
(Class<? extends PluginContext> contextType, boolean mustBeUserVisible, Class<?>... parameters) Returns executable PluginParameterBindings, which can be invoked in the given context on the given parameter types.getPluginsResultingIn
(Class<?> resultType, Class<? extends PluginContext> contextType, boolean mustBeUserVisible) Find the plugins resulting in the given type.static void
initialize
(Class<? extends PluginContext> pluginContextType) boolean
isParameterAssignable
(Class<?> instanceType, Class<?> requestedType) Returns true if the instance type can be cast to the requested type, or if the requested type is an array and the instance type can be cast to the component type of the requested type.void
register
(URL url, PackageDescriptor pack) registers a URL to this plugin manager.void
register
(URL url, PackageDescriptor pack, ClassLoader loader) registers a URL to this plugin manager.void
Removes the listener from the plugin manager.
-
Method Details
-
addListener
Description copied from interface:PluginManager
Adds a listener to the plugin manager.- Specified by:
addListener
in interfacePluginManager
- Parameters:
listener
- the listener to add.
-
getKnownClassesAnnotatedWith
Description copied from interface:PluginManager
Returns all known classes annotated with a certain annotationType. Not all of these classes are plugins! Note that only classes are available that carry the @KeepInProMCache annotation- Specified by:
getKnownClassesAnnotatedWith
in interfacePluginManager
- Parameters:
annotationType
- the type of annotation to be found- Returns:
- a (possibly empty) set of classes (not null)
-
removeListener
Description copied from interface:PluginManager
Removes the listener from the plugin manager.- Specified by:
removeListener
in interfacePluginManager
- Parameters:
listener
- the listener to remove.
-
fireError
-
firePluginAdded
-
initialize
-
getInstance
-
register
Description copied from interface:PluginManager
registers a URL to this plugin manager. If the URL uses theFILE_PROTOCOl
protocol and denotes a directory, then this folder is recursively scanned for files with theCLASS_EXTENSION
extension. Otherwise, the URL is assumed to point to a jar file, of which the classes are scanned. Each class file is scanned for classes and/or methods annotated with thePlugin
annotation. If a class is annotated with this annotation, then its methods are scanned for thePluginVariant
annotation. For each plugin found, aPluginDescriptor
object is instantiated. These plugin descriptors can later be used to invoke plugins.- Specified by:
register
in interfacePluginManager
- Parameters:
url
- The URL to registerpack
- The package that corresponds to the URL
-
register
Description copied from interface:PluginManager
registers a URL to this plugin manager. If the URL uses theFILE_PROTOCOl
protocol and denotes a directory, then this folder is recursively scanned for files with theCLASS_EXTENSION
extension. Otherwise, the URL is assumed to point to a jar file, of which the classes are scanned. Each class file is scanned for classes and/or methods annotated with thePlugin
annotation. If a class is annotated with this annotation, then its methods are scanned for thePluginVariant
annotation. For each plugin found, aPluginDescriptor
object is instantiated. These plugin descriptors can later be used to invoke plugins.- Specified by:
register
in interfacePluginManager
- Parameters:
url
- The URL to registerpack
- The package that corresponds to the URLloader
- The class loader used to load the jar files.
-
find
public Set<Pair<Integer,PluginParameterBinding>> find(Class<? extends Annotation> annotation, Class<?> resultType, Class<? extends PluginContext> contextType, boolean totalMatch, boolean orderedParameters, boolean mustBeUserVisible, Class<?>... parameters) Description copied from interface:PluginManager
This method retuns a collection ofPair
s ofInteger
andPluginParameterBinding
objects, such that:The method belonging to the plugin in the pluginParameterBinding carries the given annotation. If no specific annotation is required, the method should be called with
Plugin.class
. Note that the annotation required has to be on the same level as thePlugin
annotation, i.e. either on a method or a classWhen invoked, the PluginParameterBinding returns an array of objects, of which the object at the index given by the integer in the pair is of the required result type, i.e.
resultType.isAssignableFrom(p.getPlugin().getReturnTypes()[i])
If no specific return type is required, useObject.class
for this parameter.The PluginParameterBinding can be executed in a
PluginContext
of the given type.If
totalMatch
is true, then the PluginParameterBinding binds all parameters of the plugin with all arguments. Otherwise, the PluginParameterBinding only requires a subset of the given arguments and is therefore not directly executable on the given set of arguments.If
orderedParameters
is true, then the PluginParameterBinding binds the given arguments in the given order, i.e. no arguments are reordered.If
mustBeUserVisible
is true, then the plugin must have theisUserVisible
flag set to true.The PluginParameterBinding can be executed on arguments of the given types. The list of arguments can be empty, in which case no arguments are required to invoke the PluginParameterBinding. Note that only types of arguments are required, not the values. For checking whether arguments can be assigned to parameters of the Plugin, the
isParameterAssignable
method is used. AnyProMFuture
s should be unwrapped.- Specified by:
find
in interfacePluginManager
- Parameters:
annotation
- The annotation that should be present on the plugin (usePlugin.class
if none is required).resultType
- The required result type (useObject.class
if no specific type is required).contextType
- The context type in which this plugin should be executable. Note that this type should be the contextType of the context from which the find is called, or a supertype thereof.totalMatch
- Whether or not all arguments should be used to execute this plugin.orderedParameters
- Whether or not the arguments are given in the right order.mustBeUserVisible
- Whether or not all returned plugins should be user visible.parameters
- The types of the arguments provided to the plugin. Can be empty.- Returns:
- A collection of pluginparameterbindings. They are executable if totalMatch is true.
-
find
public Set<Pair<Integer,PluginParameterBinding>> find(Class<? extends Annotation> annotation, Class<?>[] resultTypes, Class<? extends PluginContext> contextType, boolean totalMatch, boolean orderedParameters, boolean mustBeUserVisible, Class<?>... parameters) Description copied from interface:PluginManager
This method retuns a collection ofPair
s ofInteger
andPluginParameterBinding
objects, such that:The method belonging to the plugin in the pluginParameterBinding carries the given annotation. If no specific annotation is required, the method should be called with
Plugin.class
. Note that the annotation required has to be on the same level as thePlugin
annotation, i.e. either on a method or a classWhen invoked, the PluginParameterBinding returns an array of objects, of which the object at the index given by the integer in the pair is of the required result type as specified in the input list, i.e. for all
i
resultTypes[i].isAssignableFrom(p.getPlugin().getReturnTypes()[i])
If no specific return type is required, use the otherfind
method.The PluginParameterBinding can be executed in a
PluginContext
of the given type.If
totalMatch
is true, then the PluginParameterBinding binds all parameters of the plugin with all arguments. Otherwise, the PluginParameterBinding only requires a subset of the given arguments and is therefore not directly executable on the given set of arguments.If
orderedParameters
is true, then the PluginParameterBinding binds the given arguments in the given order, i.e. no arguments are reordered.If
mustBeUserVisible
is true, then the plugin must have theisUserVisible
flag set to true.The PluginParameterBinding can be executed on arguments of the given types. The list of arguments can be empty, in which case no arguments are required to invoke the PluginParameterBinding. Note that only types of arguments are required, not the values. For checking whether arguments can be assigned to parameters of the Plugin, the
isParameterAssignable
method is used. AnyProMFuture
s should be unwrapped.- Specified by:
find
in interfacePluginManager
- Parameters:
annotation
- The annotation that should be present on the plugin (usePlugin.class
if none is required).resultTypes
- The exact, sorted list of required result types. If not specific type is requested, this find method should not be used.contextType
- The context type in which this plugin should be executable. Note that this type should be the contextType of the context from which the find is called, or a supertype thereof.totalMatch
- Whether or not all arguments should be used to execute this plugin.orderedParameters
- Whether or not the arguments are given in the right order.mustBeUserVisible
- Whether or not all returned plugins should be user visible.- Returns:
- A collection of pluginparameterbindings. They are executable if totalMatch is true.
-
find
-
getPlugin
Description copied from interface:PluginManager
Returns a PluginDescriptor with the given id. Note that plugin IDs are persistent between runs.- Specified by:
getPlugin
in interfacePluginManager
- Parameters:
id
- the id of the plugin to get- Returns:
- the plugin with the given id.
-
getPlugin
Description copied from interface:PluginManager
Returns a PluginDescriptor of which the toString() of its id equals the given id. Note that plugin IDs are persistent between runs.- Specified by:
getPlugin
in interfacePluginManager
- Parameters:
id
- the String representation of the id of the plugin to get- Returns:
- the plugin with an id of which the String representation equals the given id.
-
getPluginsAcceptingAtLeast
public Set<PluginParameterBinding> getPluginsAcceptingAtLeast(Class<? extends PluginContext> contextType, boolean mustBeUserVisible, Class<?>... parameters) Description copied from interface:PluginManager
Returns PluginParameterBindings, which can be invoked in the given context on the given parameter types. Note that the PluginParameterBindings are not necessarily executable. However, they accept all given arguments as parameters.- Specified by:
getPluginsAcceptingAtLeast
in interfacePluginManager
- Parameters:
contextType
- The type of the context in which the binding is to be invoked.mustBeUserVisible
- Whether or not the plugin should be user visible.parameters
- The types of the arguments passed to the plugins. They are accepted by the returned plugins, but not necessarily in this order.- Returns:
- a list of bindings
-
getPluginsAcceptingInAnyOrder
public Set<PluginParameterBinding> getPluginsAcceptingInAnyOrder(Class<? extends PluginContext> contextType, boolean mustBeUserVisible, Class<?>... parameters) Description copied from interface:PluginManager
Returns executable PluginParameterBindings, which can be invoked in the given context on the given parameter types. Note that the PluginParameterBindings are executable.- Specified by:
getPluginsAcceptingInAnyOrder
in interfacePluginManager
- Parameters:
contextType
- The type of the context in which the binding is to be invoked.mustBeUserVisible
- Whether or not the plugin should be user visible.parameters
- The types of the arguments passed to the plugins. They are accepted by the returned plugins, but not necessarily in this order.- Returns:
- a list of executable bindings
-
getPluginsAcceptingOrdered
public Set<PluginParameterBinding> getPluginsAcceptingOrdered(Class<? extends PluginContext> contextType, boolean mustBeUserVisible, Class<?>... parameters) Description copied from interface:PluginManager
Returns executable PluginParameterBindings, which can be invoked in the given context on the given parameter types. Note that the PluginParameterBindings are executable.- Specified by:
getPluginsAcceptingOrdered
in interfacePluginManager
- Parameters:
contextType
- The type of the context in which the binding is to be invoked.mustBeUserVisible
- Whether or not the plugin should be user visible.parameters
- The types of the arguments passed to the plugins. They are accepted by the plugin in the order in which they are provided.- Returns:
- a list of executable bindings
-
getPluginsResultingIn
public Set<Pair<Integer,PluginDescriptor>> getPluginsResultingIn(Class<?> resultType, Class<? extends PluginContext> contextType, boolean mustBeUserVisible) Description copied from interface:PluginManager
Find the plugins resulting in the given type. The result are pairs of integers and plugins, such that for each pair (i,p) holds that resultType.isAssignableFrom(p.getReturnTypes()[i])- Specified by:
getPluginsResultingIn
in interfacePluginManager
- Parameters:
resultType
- Can be null. if null, then any type is considered.mustBeUserVisible
- Whether or not all returned plugins should be user visible.- Returns:
- A collection of pairs of integers and plugins, such that for each pair (i,p) holds that resultType.isAssignableFrom(p.getReturnTypes()[i])
-
getAllPlugins
Description copied from interface:PluginManager
Returns all plugin descriptors- Specified by:
getAllPlugins
in interfacePluginManager
- Returns:
- all plugin descriptors known to the plugin manager.
-
getAllPlugins
Description copied from interface:PluginManager
Returns all plugin descriptors known to the plugin manager. If set, only those plugins which are user visible are returned.- Specified by:
getAllPlugins
in interfacePluginManager
- Parameters:
mustBeVisible
- wether or not the returned plugins should be user visible.- Returns:
- the plugin descriptors.
-
isParameterAssignable
Description copied from interface:PluginManager
Returns true if the instance type can be cast to the requested type, or if the requested type is an array and the instance type can be cast to the component type of the requested type.- Specified by:
isParameterAssignable
in interfacePluginManager
- Parameters:
instanceType
- the type that has to be cast to the requested type.requestedType
- the requested type- Returns:
- true if a cast can be made, i.e. if an object of type instanceType can be assigned to a parameter of type requestedType of a plugin.
-
getKnownObjectTypes
Description copied from interface:PluginManager
Returns the set of types that is known to the plugin manager. Basically, this set contains all types that are ever used as a parameter or a return type of a plugin.- Specified by:
getKnownObjectTypes
in interfacePluginManager
- Returns:
- a set of types.
-