public class PluginsManager extends java.lang.Object implements PluginManifestKeys
| Modifier and Type | Class and Description |
|---|---|
static class |
PluginsManager.FoundPlugin |
class |
PluginsManager.PluginPeer
This class represents a Plugin in the application.
|
| Modifier and Type | Field and Description |
|---|---|
static char |
LOG_FULL
Specifies that the initialization of the Plugin is logged and that log of exceptions during the initialization of the Plugins should
be full (ie the exceptions StackTraces should be present in the log).
|
static char |
LOG_NO
Specifies that the initialization of the Plugin is not logged.
|
static char |
LOG_SIMPLE
Specifies that the initialization of the Plugin is logged and that log of exceptions during the initialization of the Plugins should
be simple (ie the exceptions StackTraces should not be present in the log).
|
static java.net.URL |
PLUGINS_XSD
The Plugins XML configuration file Schema.
|
KEY_PLUGIN_CLASS, KEY_PLUGIN_CONFIG, KEY_PLUGIN_DEPENDENCIES, KEY_PLUGIN_FACTORY, KEY_PLUGIN_TYPE| Constructor and Description |
|---|
PluginsManager(java.io.File pluginsDir)
Constructor, with only one directory containing the Plugins paths.
|
PluginsManager(java.io.File pluginsDir,
java.io.File pluginsConfig)
Constructor, with only one directory containing the Plugins paths.
|
PluginsManager(java.util.List<java.net.URL> pluginsDirList)
Constructor, with as many URLs as necessary containing the Plugins paths.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(PluginsListener listener)
Add a Plugin Listener.
|
boolean |
applyCommandLineArguments()
Apply the launch arguments.
|
void |
dispose()
Ask each Plugin to dispose of its resources.
|
void |
emitException(java.lang.Throwable e,
java.lang.String message,
short type)
Emit an exception.
|
void |
emitException(java.lang.Throwable e,
java.lang.String message,
java.lang.String name,
short type)
Emit an exception for a Plugin.
|
boolean |
executeCustomAction(java.lang.String actionName,
short blockingType,
java.lang.Object... arguments)
Execute a custom action.
|
java.net.URLClassLoader |
getClassloader()
Return the classLoader used to load the plugins.
|
java.util.Map<java.lang.String,java.lang.Short> |
getCustomActions()
Return the custom actions.
|
java.util.Map<java.lang.String,java.lang.Boolean> |
getEnabledPlugins()
Returned the enabled Plugins of this application.
|
java.util.Map<java.lang.String,Plugin> |
getLoadablePlugins()
Return the map of loadable plugins.
|
java.util.Map<java.lang.String,Plugin> |
getLoadedPluginList()
Return the list of available Plugins, for the plugins who have successfuly been loaded.
|
java.util.List<PluginsManager.PluginPeer> |
getLoadedPluginPeer() |
java.util.List<Plugin> |
getLoadedPlugins()
Return the list of loaded Plugins.
|
MDIApplication |
getMDIApplication()
Return the application.
|
java.util.Map<java.lang.String,PluginsManager.PluginPeer> |
getPluginList()
Return the list of available Plugins.
|
PluginsConfigurations |
getPluginsConfigurations()
Return the Plugins configurations.
|
short |
getPluginsDeactivationPolicy()
Return the plugins deactivation policy.
|
int |
getPluginsSize()
Return the number of loaded Plugins.
|
java.io.File |
getStartDirectory()
Return the starting directory.
|
boolean |
hasDisabledPlugins()
Returned true if there are disabled Plugins of this application.
|
boolean |
hasPluginsConfigurations()
Return true if there are Plugins configurations.
|
void |
initAfterGUI(MDIApplication app)
Called after the GUI initialization.
|
void |
initPlugins(MDIApplication app)
Initialize all plugins.
|
boolean |
isEarlyConfigurationPlugin(java.lang.String pluginName)
Return true if a plugin has an early configuration.
|
boolean |
isEnabled(Plugin plugin)
Return true if a plugin is enabled.
|
boolean |
isEnabled(java.lang.String pluginName)
Return true if a plugin of a specified name is enabled.
|
boolean |
isFactoryPlugin(java.lang.String pluginName)
Return true if a plugin is created from a factory.
|
boolean |
isLoggingRegisterProgress()
Return true if the plugins register progress is logged.
|
java.lang.Object |
loadAndInstanciatePluginClass(java.lang.String name)
Load a class found in a Plugin, and create a new instance from this class.
|
java.lang.Class<?> |
loadPluginClass(java.lang.String name)
Load a class found in a Plugin.
|
void |
logRegisterProgress(boolean isLogging)
Set if the plugins register progress is logged.
|
void |
logRegisterProgress(char logProgress)
Set if and how the plugins register progress is logged.
|
void |
registerPlugins(MDIApplication app)
Register all Plugins.
|
void |
removeListener(PluginsListener listener)
Remove a Plugin listener.
|
void |
resetPluginSettings()
Reset all the Plugins Settings.
|
void |
setAdditionalPluginTypes(java.util.Map<java.lang.String,AppliManifestType> additionalPluginTypes)
Set additional Plugin types for the Plugin manager.
|
void |
setAllowedPluginTypes(java.util.Map<java.lang.String,java.lang.Boolean> allowedPluginTypes)
Set the allowed Plugins Types for the Plugin manager.
|
void |
setApplicationID(java.lang.String applicationID)
Set the Application ID.
|
void |
setConfigurationManager(ConfigurationManager configManager)
Set the configuration manager.
|
void |
setCustomActions(java.util.Map<java.lang.String,java.lang.Short> customActions)
Add a custom action.
|
void |
setEnabledPlugins(java.util.Map<java.lang.String,java.lang.Boolean> enabledPlugins)
Returned the enabled Plugins of this application.
|
void |
setManagerListener(PluginsManagerListener listener)
Set a listener which will be fired for each exception encountered during the Plugins loading, or some informations on the Plugins
loading.
|
void |
setMDIApplication(MDIApplication app)
Set the application.
|
void |
setPluginsDeactivationPolicy(short policy)
Set the plugins deactivation policy
|
void |
setPluginsEDTSupport(PluginsEDTSupport pluginsEDTSupport)
Set the initialization support of the
MDIPlugins. |
void |
setProgress(ProgressInterface progress,
int progressMax)
Configure the Progress bar during the Plugins loading and initialization.
|
void |
setStartDirectory(java.io.File dir)
Set the starting directory.
|
public static final java.net.URL PLUGINS_XSD
public static final char LOG_NO
public static final char LOG_SIMPLE
public static final char LOG_FULL
public PluginsManager(java.io.File pluginsDir,
java.io.File pluginsConfig)
Plugin class is
defined in a XML File.
The Schema of the File is:
<xs:element name="Plugins">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="plugin" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="plugin">
<xs:complexType>
<xs:attribute name="mainclass" type="xs:string" use="required" />
<xs:attribute name="desc" type="xs:string" />
</xs:complexType>
</xs:element>
Example, for one Plugin:
<Plugins> <plugin mainclass="org.mdi.examples.simple.plugins.OpenImagePlugin" desc="OpenImagePlugin" /> </Plugins>
pluginsDir - the directory were to look for Plugins packaged as Jar FilespluginsConfig - the XML File name used to define the path to the Plugin classespublic PluginsManager(java.util.List<java.net.URL> pluginsDirList)
Plugin
class is in the Plugin Manifest.
The Manifest contain several specific attributes:
Plugin classpluginsDirList - the URL list listing directories containing the plugins, or the plugins Jar themselvespublic PluginsManager(java.io.File pluginsDir)
Plugin class is
in the Plugin Manifest.
The Manifest contain several specific attributes:
Plugin classpluginsDir - the directory were to look for Plugins packaged as Jar Filespublic void setMDIApplication(MDIApplication app)
app - the applicationpublic MDIApplication getMDIApplication()
public void setConfigurationManager(ConfigurationManager configManager)
configManager - the configuration managerpublic void logRegisterProgress(boolean isLogging)
isLogging) - true if the plugins register progress is loggedpublic void logRegisterProgress(char logProgress)
logProgress - specified how the plugins register progress is loggedpublic boolean isLoggingRegisterProgress()
public void setStartDirectory(java.io.File dir)
dir - the starting directorypublic java.io.File getStartDirectory()
public void setPluginsEDTSupport(PluginsEDTSupport pluginsEDTSupport)
MDIPlugins.pluginsEDTSupport - the EDT supportMDIPluginsInitModepublic void setManagerListener(PluginsManagerListener listener)
listener - the listenerpublic void setApplicationID(java.lang.String applicationID)
applicationID - the Application IDpublic void setProgress(ProgressInterface progress, int progressMax)
progress - the Progress barprogressMax - the maximum value of the progress bar at the end of the initializationpublic void setAdditionalPluginTypes(java.util.Map<java.lang.String,AppliManifestType> additionalPluginTypes)
setAllowedPluginTypes(java.util.Map), the manifest key for these types is up to the application. It allows to define
additional constraints which will define if Plugins will be loaded.
additionalPluginTypes - the Map of additional Plugin typespublic void setAllowedPluginTypes(java.util.Map<java.lang.String,java.lang.Boolean> allowedPluginTypes)
allowedPluginTypes - the allowed Plugin Types as a MapsetAdditionalPluginTypes(java.util.Map)public java.net.URLClassLoader getClassloader()
public java.lang.Class<?> loadPluginClass(java.lang.String name)
It is necessary to use this method to load any classes found in Plugins, except the core class that implements the Plugin
interface, because only the PluginManager get holds of the classLoader that is able to load all the Plugins
name - the class namepublic void emitException(java.lang.Throwable e,
java.lang.String message,
short type)
e - the throwablemessage - the messagetype - the exception typepublic void emitException(java.lang.Throwable e,
java.lang.String message,
java.lang.String name,
short type)
e - the throwablemessage - the messagename - the plugin nametype - the exception typepublic void initAfterGUI(MDIApplication app)
MDIPlugin.initAfterGUI(org.mdi.bootstrap.MDIApplication) for each
MDIPlugin.app - the MDIApplicationpublic boolean applyCommandLineArguments()
public java.lang.Object loadAndInstanciatePluginClass(java.lang.String name)
name - the class nameloadPluginClass(String)public void addListener(PluginsListener listener)
listener - the Plugin Listenerpublic void removeListener(PluginsListener listener)
listener - the Plugin Listenerpublic int getPluginsSize()
public void resetPluginSettings()
public void initPlugins(MDIApplication app)
app - the Applicationpublic boolean hasPluginsConfigurations()
public PluginsConfigurations getPluginsConfigurations()
public boolean isEnabled(Plugin plugin)
plugin - the pluginpublic boolean isEnabled(java.lang.String pluginName)
pluginName - the plugin namepublic boolean isFactoryPlugin(java.lang.String pluginName)
pluginName - the plugin namepublic boolean isEarlyConfigurationPlugin(java.lang.String pluginName)
pluginName - the plugin namepublic void registerPlugins(MDIApplication app) throws org.xml.sax.SAXException, java.io.IOException
Plugin classapp - the Applicationorg.xml.sax.SAXException - if a SAXException is encountered while registering the Pluginsjava.io.IOException - if an IOException is encountered while registering the Pluginspublic java.util.List<Plugin> getLoadedPlugins()
getPluginList()public java.util.List<PluginsManager.PluginPeer> getLoadedPluginPeer()
public java.util.Map<java.lang.String,PluginsManager.PluginPeer> getPluginList()
PluginsManager.PluginPeer.
A Plugin in the plugin configuration file will be added in this list if the loading process of the Plugin main class is successful.
However, the Plugin will really be loaded (and associated actions created) only if it have been enabled.getLoadedPlugins(),
getLoadedPluginList()public java.util.Map<java.lang.String,Plugin> getLoadablePlugins()
public void dispose()
public java.util.Map<java.lang.String,Plugin> getLoadedPluginList()
getLoadedPlugins()public void setPluginsDeactivationPolicy(short policy)
policy - the policypublic short getPluginsDeactivationPolicy()
public void setEnabledPlugins(java.util.Map<java.lang.String,java.lang.Boolean> enabledPlugins)
enabledPlugins - the enabled Pluginspublic java.util.Map<java.lang.String,java.lang.Boolean> getEnabledPlugins()
public boolean hasDisabledPlugins()
public void setCustomActions(java.util.Map<java.lang.String,java.lang.Short> customActions)
customActions - the custom actionspublic java.util.Map<java.lang.String,java.lang.Short> getCustomActions()
public boolean executeCustomAction(java.lang.String actionName,
short blockingType,
java.lang.Object... arguments)
actionName - the custom action nameblockingType - the blocking typearguments - the arguments