Class PluginManagerImpl
- java.lang.Object
-
- org.processmining.framework.plugin.impl.PluginManagerImpl
-
- All Implemented Interfaces:
PluginManager
public final class PluginManagerImpl extends java.lang.Object implements 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(PluginManager.PluginManagerListener listener)Adds a listener to the plugin manager.java.util.Set<Pair<java.lang.Integer,PluginParameterBinding>>find(java.lang.Class<? extends java.lang.annotation.Annotation> annotation, java.lang.Class<?>[] resultTypes, java.lang.Class<? extends PluginContext> contextType, boolean totalMatch, boolean orderedParameters, boolean mustBeUserVisible, java.lang.Class<?>... parameters)This method retuns a collection ofPairs ofIntegerandPluginParameterBindingobjects, such that:java.util.Set<Pair<java.lang.Integer,PluginParameterBinding>>find(java.lang.Class<? extends java.lang.annotation.Annotation> annotation, java.lang.Class<?> resultType, java.lang.Class<? extends PluginContext> contextType, boolean totalMatch, boolean orderedParameters, boolean mustBeUserVisible, java.lang.Class<?>... parameters)This method retuns a collection ofPairs ofIntegerandPluginParameterBindingobjects, such that:java.util.Collection<PluginDescriptor>find(java.lang.String pluginName)protected voidfireError(java.net.URL url, java.lang.Throwable t, java.lang.String className)protected voidfirePluginAdded(PluginDescriptor plugin, java.util.Collection<java.lang.Class<?>> types)java.util.SortedSet<PluginDescriptor>getAllPlugins()Returns all plugin descriptorsjava.util.SortedSet<PluginDescriptor>getAllPlugins(boolean mustBeVisible)Returns all plugin descriptors known to the plugin manager.static PluginManagergetInstance()java.util.Set<java.lang.Class<?>>getKnownClassesAnnotatedWith(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)Returns all known classes annotated with a certain annotationType.java.util.Set<java.lang.Class<?>>getKnownObjectTypes()Returns the set of types that is known to the plugin manager.PluginDescriptorgetPlugin(java.lang.String id)Returns a PluginDescriptor of which the toString() of its id equals the given id.PluginDescriptorgetPlugin(PluginDescriptorID id)Returns a PluginDescriptor with the given id.java.util.Set<PluginParameterBinding>getPluginsAcceptingAtLeast(java.lang.Class<? extends PluginContext> contextType, boolean mustBeUserVisible, java.lang.Class<?>... parameters)Returns PluginParameterBindings, which can be invoked in the given context on the given parameter types.java.util.Set<PluginParameterBinding>getPluginsAcceptingInAnyOrder(java.lang.Class<? extends PluginContext> contextType, boolean mustBeUserVisible, java.lang.Class<?>... parameters)Returns executable PluginParameterBindings, which can be invoked in the given context on the given parameter types.java.util.Set<PluginParameterBinding>getPluginsAcceptingOrdered(java.lang.Class<? extends PluginContext> contextType, boolean mustBeUserVisible, java.lang.Class<?>... parameters)Returns executable PluginParameterBindings, which can be invoked in the given context on the given parameter types.java.util.Set<Pair<java.lang.Integer,PluginDescriptor>>getPluginsResultingIn(java.lang.Class<?> resultType, java.lang.Class<? extends PluginContext> contextType, boolean mustBeUserVisible)Find the plugins resulting in the given type.static voidinitialize(java.lang.Class<? extends PluginContext> pluginContextType)booleanisParameterAssignable(java.lang.Class<?> instanceType, java.lang.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.voidregister(java.net.URL url, PackageDescriptor pack)registers a URL to this plugin manager.voidregister(java.net.URL url, PackageDescriptor pack, java.lang.ClassLoader loader)registers a URL to this plugin manager.voidremoveListener(PluginManager.PluginManagerListener listener)Removes the listener from the plugin manager.
-
-
-
Method Detail
-
addListener
public void addListener(PluginManager.PluginManagerListener listener)
Description copied from interface:PluginManagerAdds a listener to the plugin manager.- Specified by:
addListenerin interfacePluginManager- Parameters:
listener- the listener to add.
-
getKnownClassesAnnotatedWith
public java.util.Set<java.lang.Class<?>> getKnownClassesAnnotatedWith(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Description copied from interface:PluginManagerReturns 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:
getKnownClassesAnnotatedWithin interfacePluginManager- Parameters:
annotationType- the type of annotation to be found- Returns:
- a (possibly empty) set of classes (not null)
-
removeListener
public void removeListener(PluginManager.PluginManagerListener listener)
Description copied from interface:PluginManagerRemoves the listener from the plugin manager.- Specified by:
removeListenerin interfacePluginManager- Parameters:
listener- the listener to remove.
-
fireError
protected void fireError(java.net.URL url, java.lang.Throwable t, java.lang.String className)
-
firePluginAdded
protected void firePluginAdded(PluginDescriptor plugin, java.util.Collection<java.lang.Class<?>> types)
-
initialize
public static void initialize(java.lang.Class<? extends PluginContext> pluginContextType)
-
getInstance
public static PluginManager getInstance()
-
register
public void register(java.net.URL url, PackageDescriptor pack)Description copied from interface:PluginManagerregisters a URL to this plugin manager. If the URL uses theFILE_PROTOCOlprotocol and denotes a directory, then this folder is recursively scanned for files with theCLASS_EXTENSIONextension. 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 thePluginannotation. If a class is annotated with this annotation, then its methods are scanned for thePluginVariantannotation. For each plugin found, aPluginDescriptorobject is instantiated. These plugin descriptors can later be used to invoke plugins.- Specified by:
registerin interfacePluginManager- Parameters:
url- The URL to registerpack- The package that corresponds to the URL
-
register
public void register(java.net.URL url, PackageDescriptor pack, java.lang.ClassLoader loader)Description copied from interface:PluginManagerregisters a URL to this plugin manager. If the URL uses theFILE_PROTOCOlprotocol and denotes a directory, then this folder is recursively scanned for files with theCLASS_EXTENSIONextension. 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 thePluginannotation. If a class is annotated with this annotation, then its methods are scanned for thePluginVariantannotation. For each plugin found, aPluginDescriptorobject is instantiated. These plugin descriptors can later be used to invoke plugins.- Specified by:
registerin 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 java.util.Set<Pair<java.lang.Integer,PluginParameterBinding>> find(java.lang.Class<? extends java.lang.annotation.Annotation> annotation, java.lang.Class<?> resultType, java.lang.Class<? extends PluginContext> contextType, boolean totalMatch, boolean orderedParameters, boolean mustBeUserVisible, java.lang.Class<?>... parameters)
Description copied from interface:PluginManagerThis method retuns a collection ofPairs ofIntegerandPluginParameterBindingobjects, 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 thePluginannotation, 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.classfor this parameter.The PluginParameterBinding can be executed in a
PluginContextof the given type.If
totalMatchis 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
orderedParametersis true, then the PluginParameterBinding binds the given arguments in the given order, i.e. no arguments are reordered.If
mustBeUserVisibleis true, then the plugin must have theisUserVisibleflag 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
isParameterAssignablemethod is used. AnyProMFutures should be unwrapped.- Specified by:
findin interfacePluginManager- Parameters:
annotation- The annotation that should be present on the plugin (usePlugin.classif none is required).resultType- The required result type (useObject.classif 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 java.util.Set<Pair<java.lang.Integer,PluginParameterBinding>> find(java.lang.Class<? extends java.lang.annotation.Annotation> annotation, java.lang.Class<?>[] resultTypes, java.lang.Class<? extends PluginContext> contextType, boolean totalMatch, boolean orderedParameters, boolean mustBeUserVisible, java.lang.Class<?>... parameters)
Description copied from interface:PluginManagerThis method retuns a collection ofPairs ofIntegerandPluginParameterBindingobjects, 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 thePluginannotation, 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
iresultTypes[i].isAssignableFrom(p.getPlugin().getReturnTypes()[i])If no specific return type is required, use the otherfindmethod.The PluginParameterBinding can be executed in a
PluginContextof the given type.If
totalMatchis 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
orderedParametersis true, then the PluginParameterBinding binds the given arguments in the given order, i.e. no arguments are reordered.If
mustBeUserVisibleis true, then the plugin must have theisUserVisibleflag 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
isParameterAssignablemethod is used. AnyProMFutures should be unwrapped.- Specified by:
findin interfacePluginManager- Parameters:
annotation- The annotation that should be present on the plugin (usePlugin.classif 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
public java.util.Collection<PluginDescriptor> find(java.lang.String pluginName)
-
getPlugin
public PluginDescriptor getPlugin(PluginDescriptorID id)
Description copied from interface:PluginManagerReturns a PluginDescriptor with the given id. Note that plugin IDs are persistent between runs.- Specified by:
getPluginin interfacePluginManager- Parameters:
id- the id of the plugin to get- Returns:
- the plugin with the given id.
-
getPlugin
public PluginDescriptor getPlugin(java.lang.String id)
Description copied from interface:PluginManagerReturns a PluginDescriptor of which the toString() of its id equals the given id. Note that plugin IDs are persistent between runs.- Specified by:
getPluginin 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 java.util.Set<PluginParameterBinding> getPluginsAcceptingAtLeast(java.lang.Class<? extends PluginContext> contextType, boolean mustBeUserVisible, java.lang.Class<?>... parameters)
Description copied from interface:PluginManagerReturns 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:
getPluginsAcceptingAtLeastin 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 java.util.Set<PluginParameterBinding> getPluginsAcceptingInAnyOrder(java.lang.Class<? extends PluginContext> contextType, boolean mustBeUserVisible, java.lang.Class<?>... parameters)
Description copied from interface:PluginManagerReturns executable PluginParameterBindings, which can be invoked in the given context on the given parameter types. Note that the PluginParameterBindings are executable.- Specified by:
getPluginsAcceptingInAnyOrderin 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 java.util.Set<PluginParameterBinding> getPluginsAcceptingOrdered(java.lang.Class<? extends PluginContext> contextType, boolean mustBeUserVisible, java.lang.Class<?>... parameters)
Description copied from interface:PluginManagerReturns executable PluginParameterBindings, which can be invoked in the given context on the given parameter types. Note that the PluginParameterBindings are executable.- Specified by:
getPluginsAcceptingOrderedin 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 java.util.Set<Pair<java.lang.Integer,PluginDescriptor>> getPluginsResultingIn(java.lang.Class<?> resultType, java.lang.Class<? extends PluginContext> contextType, boolean mustBeUserVisible)
Description copied from interface:PluginManagerFind 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:
getPluginsResultingInin 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
public java.util.SortedSet<PluginDescriptor> getAllPlugins()
Description copied from interface:PluginManagerReturns all plugin descriptors- Specified by:
getAllPluginsin interfacePluginManager- Returns:
- all plugin descriptors known to the plugin manager.
-
getAllPlugins
public java.util.SortedSet<PluginDescriptor> getAllPlugins(boolean mustBeVisible)
Description copied from interface:PluginManagerReturns all plugin descriptors known to the plugin manager. If set, only those plugins which are user visible are returned.- Specified by:
getAllPluginsin interfacePluginManager- Parameters:
mustBeVisible- wether or not the returned plugins should be user visible.- Returns:
- the plugin descriptors.
-
isParameterAssignable
public boolean isParameterAssignable(java.lang.Class<?> instanceType, java.lang.Class<?> requestedType)Description copied from interface:PluginManagerReturns 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:
isParameterAssignablein 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
public java.util.Set<java.lang.Class<?>> getKnownObjectTypes()
Description copied from interface:PluginManagerReturns 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:
getKnownObjectTypesin interfacePluginManager- Returns:
- a set of types.
-
-