public class PluginFactory extends Object
Created object is connected with directory where plugins exist. This directory is scanned for
jar
files that meet given below naming conventions. Every file that meets naming convention is loaded
and asked for method IQuimpPlugin.setup(). On success the plugin is registered in availPlugins
database:
<Name, <File, Type, ClassName>>
Where Name is name of plugin extracted form file name (see below required naming conventions), File is handle to file on disk, Type is type of plugin according to types defined in warwick.wsbc.plugin.IQuimpPlugin and ClassName is qualified name of class of plugin. The ClassName is extracted from the plugin jar file assuming that plugin class contains underscore _ in its name. If more classes underscored is found in jar, only the first discovered is loaded. Thus the following conventions are required:
Simplified sequence diagrams are as follows:
This class try to hide all exceptions that can be thrown during loading plugins from user. In general only when user pass wrong path to plugins directory exception is thrown. In all other cases class returns null pointers or empty lists. Error handling:
Each jar is loaded only once on first request. Next requests get the same instance.
Constructor and Description |
---|
PluginFactory(Path path)
Build object connected to plugin directory.
|
Modifier and Type | Method and Description |
---|---|
IQuimpCorePlugin |
getInstance(String name)
Return instance of named plugin.
|
ArrayList<String> |
getPluginNames(int type)
Return list of plugins of given types.
|
Map<String,PluginProperties> |
getRegisterdPlugins()
Accessor to internal database of loaded plugins.
|
static void |
getSystemClassPath()
Prints system classpath.
|
public PluginFactory(Path path)
Can throw exception if there is no directory path.
path
- public Map<String,PluginProperties> getRegisterdPlugins()
public ArrayList<String> getPluginNames(int type)
type
- Type defined in com.github.celldynamics.plugin.IQuimpPluginpublic IQuimpCorePlugin getInstance(String name)
JAR is loaded only once on first request. Then its reference is stored in
PluginProperties
and served on next demand. Thus, if plugin is used on different frames
in stack it is the same instance.
name
- Name of plugin compatible with general rulespublic static void getSystemClassPath()
Copyright © 2002–2019 Department of Computer Science, Warwick University. All rights reserved.