Package org.jorigin.plugin
Class PluginToolkit
- java.lang.Object
-
- org.jorigin.plugin.PluginToolkit
-
public class PluginToolkit extends java.lang.ObjectThis class is a toolkit used for helping plugin management. Using this class, user can scan and load a list of plugins related to a given package (setPluginPackage(String)) from given locations on the system (addPluginDir(String),addPluginDir(File)). The plugin loading is launched via theloadPlugins()method.- Since:
- 1.0.0
- Author:
- Julien Seinturier - (c) 2009 - JOrigin project - http:/www.jorigin.org
-
-
Field Summary
Fields Modifier and Type Field Description protected javax.swing.event.EventListenerListidListenerList
-
Constructor Summary
Constructors Constructor Description PluginToolkit()Constuct a new default plugin toolkit.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddPluginDir(java.io.File pluginDir)Add a new path in the plugin search path.booleanaddPluginDir(java.lang.String pluginDir)Add a new path in the plugin search path.voidaddPluginToolkitListener(PluginToolkitListener l)Add a Plugin Toolkit Listener to this plugin toolkitprotected voidfireEvent(PluginToolkitEvent e)Fire a new plugin toolkit event to all registered listenersjava.util.ArrayList<IPlugin>loadPlugins()Load all plugins available in the locations given to the toolkit.booleanremovePluginDir(java.io.File pluginDir)Remove the given path from the plugin search path list.booleanremovePluginDir(java.lang.String pluginDir)Remove the given path from the plugin search path list.voidremovePluginToolkitListener(PluginToolkitListener l)Remove a Plugin Toolkit Listener from this plugin toolkitvoidsetPluginPackage(java.lang.String pluginPackage)Set the core package of the plugins.
-
-
-
Method Detail
-
addPluginDir
public boolean addPluginDir(java.lang.String pluginDir)
Add a new path in the plugin search path.- Parameters:
pluginDir- the path to insert in the plugin search list.- Returns:
- boolean true if the plugin search dir is added, false otherwise.
-
addPluginDir
public boolean addPluginDir(java.io.File pluginDir)
Add a new path in the plugin search path.- Parameters:
pluginDir- the path to insert in the plugin search list.- Returns:
- boolean true if the plugin search dir is added, false otherwise.
-
removePluginDir
public boolean removePluginDir(java.lang.String pluginDir)
Remove the given path from the plugin search path list.- Parameters:
pluginDir- the plugin directory to remove.- Returns:
- true if the directory is succesfully removed, false otherwise.
-
removePluginDir
public boolean removePluginDir(java.io.File pluginDir)
Remove the given path from the plugin search path list.- Parameters:
pluginDir- the plugin directory to remove.- Returns:
- true if the directory is succesfully removed, false otherwise.
-
setPluginPackage
public void setPluginPackage(java.lang.String pluginPackage)
Set the core package of the plugins.- Parameters:
pluginPackage- the core package of the plugins
-
addPluginToolkitListener
public void addPluginToolkitListener(PluginToolkitListener l)
Add a Plugin Toolkit Listener to this plugin toolkit- Parameters:
l- the listener to add to the toolkit- See Also:
fireEvent(PluginToolkitEvent),removePluginToolkitListener(PluginToolkitListener)
-
removePluginToolkitListener
public void removePluginToolkitListener(PluginToolkitListener l)
Remove a Plugin Toolkit Listener from this plugin toolkit- Parameters:
l- the listener to remove- See Also:
addPluginToolkitListener(PluginToolkitListener),fireEvent(PluginToolkitEvent)
-
fireEvent
protected void fireEvent(PluginToolkitEvent e)
Fire a new plugin toolkit event to all registered listeners- Parameters:
e- the event to fire.- See Also:
addPluginToolkitListener(PluginToolkitListener),removePluginToolkitListener(PluginToolkitListener)
-
loadPlugins
public java.util.ArrayList<IPlugin> loadPlugins()
Load all plugins available in the locations given to the toolkit. This method scan the available locations and looks for plugins with given package name. When available plugins are detected, the method instanciate them and store the instanciated plugins in the returned list.- Returns:
- ArrayList<
IPlugin> the plugins availables and instanciated. - See Also:
addPluginDir(String),addPluginDir(File),removePluginDir(String),removePluginDir(File)
-
-