public abstract class AbstractApplication extends java.lang.Object implements MDIApplication, PluginsListener, CommandLineListener
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<java.lang.String,AppliManifestType> |
additionalPluginTypes
The additional Plugins Types, optional property.
|
protected java.util.Map<java.lang.String,java.lang.Boolean> |
allowedPluginTypes
The allowed Plugins Types, optional property.
|
protected ApplicationDesc |
appDesc
The application description.
|
protected java.util.Map<java.lang.String,java.lang.String> |
argsMap
The arguments map (null by default).
|
protected CommandLineHandler |
commandLineHandler
The command-line handler.
|
protected Configuration |
conf
The associated Configuration.
|
protected ConfigurationManager |
confmanager
The MDIApplication associated ConfigurationManager.
|
protected java.util.Map<java.lang.String,java.lang.Short> |
customActions
The map of custom actions.
|
protected ErrorLogger |
errorLogger
The Error logger.
|
protected java.util.List<Plugin> |
plugins
The list of loaded Plugins.
|
protected java.io.File |
pluginsConfiguration
The plugins definition xml file name.
|
protected boolean |
pluginsDefInFile
True if the plugins definition is stored in a XML File (false by default).
|
protected java.io.File |
pluginsDir
The plugins directory.
|
protected PluginsManager |
pluginsManager
The MDIApplication associated PluginsManager.
|
protected java.util.Map<java.lang.String,Plugin> |
pluginsMap
The Map of loaded Plugins.
|
protected ThreadQueue |
queue
The MDIApplication associated ThreadQueue (managing Actions).
|
protected long |
time
Store the current time when tarting an action, and the time to execute the action after it has been executed.
|
Constructor and Description |
---|
AbstractApplication() |
Modifier and Type | Method and Description |
---|---|
protected void |
addAdditionalPluginType(java.lang.String key,
AppliManifestType manifestType)
Add an additional Plugin type.
|
void |
addCustomAction(java.lang.String actionName,
short customActionType)
Add a custom action.
|
void |
addPluginDirectory(java.net.URL pluginDir)
Add an URL defining a directory where to look for Plugins.
|
protected void |
applyCommandLineArguments()
Apply the command-line arguments to both the application and its plugins.
|
protected abstract ThreadQueue |
createThreadQueue()
Create the ThreadQueue.
|
void |
disposeApplication()
Dispose of the Application, and serialize its resources if a Configuration manager has been set.
|
void |
endAction(MDIAction action)
Ends a generic action.
|
void |
executeAction(MDIAction action,
short blockingType)
Execute a generic Action.
|
void |
executeAction(MDIAction action,
short blockingType,
java.lang.ClassLoader loader)
Execute a generic Action, using a specific Classloader.
|
boolean |
executeCustomAction(java.lang.String actionName,
java.lang.Object... arguments)
Execute a blocking custom action.
|
boolean |
executeCustomAction(java.lang.String actionName,
short blockingType,
java.lang.Object... arguments)
Execute a custom action.
|
java.util.Map<java.lang.String,AppliManifestType> |
getAdditionalPluginTypes()
Return the optional additional Plugin Types.
|
java.util.Map<java.lang.String,java.lang.Boolean> |
getAllowedPluginTypes()
Return the allowed Plugin Types.
|
ApplicationDesc |
getApplicationDesc()
Return the Application description.
|
java.util.Map<java.lang.String,java.lang.String> |
getCommandLineArguments()
Return the launch arguments of the application.
|
CommandLineHandler |
getCommandLineHandler()
Return the command-line handler.
|
ConfigurationManager |
getConfigurationManager()
Return the Configuration Manager.
|
ErrorLogger |
getErrorLogger()
Return the error logger.
|
Plugin |
getPlugin(java.lang.String clazz)
Return the Plugin, given its associated class path.
|
Plugin |
getPluginForName(java.lang.String name)
Return the Plugin, given its associated name.
|
java.util.List<Plugin> |
getPlugins()
Return the Plugins List.
|
PluginsManager |
getPluginsManager()
Return the PluginsManager.
|
java.util.Map<java.lang.String,Plugin> |
getPluginsMap()
Return Plugins Map.
|
ThreadQueue |
getThreadQueue()
Return the MDIApplication ThreadQueue.
|
long |
getTime()
Return the time after the last operation.
|
boolean |
hasPlugin(java.lang.String name)
Return true if the application has a Plugin of the specified name.
|
boolean |
hasPluginsDirectories()
Return true if there is a plugins directpry or directory List.
|
boolean |
hasPluginsDirectoryList()
Return true if there is a plugins directory List.
|
boolean |
hasSinglePluginsDirectory()
Return true if there is a single plugins directory.
|
protected void |
initConfiguration()
Creates the Configuration, with no root Preferences.
|
protected void |
initConfiguration(java.util.prefs.Preferences prefRoot)
Creates the Configuration, and initialize it with a root Preference.
|
protected void |
initConfiguration(java.util.prefs.Preferences prefRoot,
java.io.File dir)
Creates the Configuration, and initialize it with a root Preference.
|
protected void |
initConfiguration(java.util.prefs.Preferences prefRoot,
java.io.File dir,
short mdiPluginsInitMode)
Creates the Configuration, and initialize it with a root Preference.
|
protected void |
initConfiguration(java.util.prefs.Preferences prefRoot,
short mdiPluginsInitMode)
Creates the Configuration, and initialize it with a root Preference.
|
protected void |
initProcessFromRegister()
Call the initialization process when in the register phase of the Plugins.
|
boolean |
isDefaultBlockingActions()
Return true if actions are blocking by default.
|
protected void |
loadResources()
Load resources (as Icons) used in the Application.
|
void |
noTimeMessages()
Do nothing by default.
|
void |
noWriteMessages()
Do nothing by default.
|
void |
pluginsActionPerformed(PluginsEvent event)
Does nothing by default.
|
protected void |
registerPlugins()
Register the Plugins.
|
protected void |
serializeConfiguration()
Serialize the configuration.
|
void |
setAllowedPluginTypes(java.util.Map<java.lang.String,java.lang.Boolean> allowedPluginTypes)
Set the allowed Plugin Types.
|
void |
setCommandLineArguments(java.util.Map<java.lang.String,java.lang.String> args)
Set the command-line arguments.
|
void |
setCommandLineArguments(java.lang.String[] args)
Set the command-line arguments.
|
void |
setCommandLineArguments(java.lang.String[] args,
boolean keepDash)
Set the command-line arguments.
|
void |
setCommandLineHandler(CommandLineHandler handler)
Set the command-line handler.
|
protected void |
setConfiguration(Configuration conf)
Set the application configuration.
|
void |
setDefaultBlockingActions(boolean isBlocking)
Set if actions are blocking by default.
|
void |
setErrorLogger(ErrorLogger errorLogger)
Set the error logger.
|
protected void |
setPluginsConfiguration(java.io.File pluginsDir)
Set the plugins directory.
|
protected void |
setPluginsConfiguration(java.io.File pluginsDir,
java.lang.String pluginsConfigFileName)
Set the plugins configuration for the application.
|
protected void |
setPluginsConfigurationFile(java.io.File pluginsDir,
java.io.File pluginsConfiguration)
Set the plugins configuration for the application.
|
void |
showActionException(java.lang.String message,
java.lang.Exception e)
Show the Exception stackTrace by default.
|
void |
startTime(MDIAction action)
Start to count the time for the last operation, and show the statusBar progress.
|
long |
stopTime(MDIAction action)
Return the time after the last operation and stop the progress bar if there is any.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
executeAction, executeAction, getApplicationID, getPluginsEDTSupport, getStartDirectory
getCommandLineConfiguration, handleCommandLineArguments, handleCommandLineArguments, handleCommandLineException
protected Configuration conf
protected ApplicationDesc appDesc
protected volatile long time
protected java.util.List<Plugin> plugins
protected java.util.Map<java.lang.String,Plugin> pluginsMap
protected java.io.File pluginsDir
protected ThreadQueue queue
protected java.io.File pluginsConfiguration
protected java.util.Map<java.lang.String,java.lang.Boolean> allowedPluginTypes
protected java.util.Map<java.lang.String,AppliManifestType> additionalPluginTypes
protected boolean pluginsDefInFile
pluginsConfiguration
protected ConfigurationManager confmanager
protected PluginsManager pluginsManager
protected java.util.Map<java.lang.String,java.lang.Short> customActions
protected ErrorLogger errorLogger
protected CommandLineHandler commandLineHandler
protected java.util.Map<java.lang.String,java.lang.String> argsMap
protected final void initConfiguration()
public ApplicationDesc getApplicationDesc()
getApplicationDesc
in interface MDIApplication
public java.util.Map<java.lang.String,java.lang.Boolean> getAllowedPluginTypes()
PluginsManager.KEY_PLUGIN_TYPE
attribute in their manifest will have to
match one of the Application allowed plugin type names.getAllowedPluginTypes
in interface MDIApplication
public java.util.Map<java.lang.String,AppliManifestType> getAdditionalPluginTypes()
getAdditionalPluginTypes
in interface MDIApplication
PluginsManager.setAdditionalPluginTypes(java.util.Map)
public final void addPluginDirectory(java.net.URL pluginDir)
pluginDir
- the directory as an URLpublic final void setAllowedPluginTypes(java.util.Map<java.lang.String,java.lang.Boolean> allowedPluginTypes)
PluginsManager.KEY_PLUGIN_TYPE
attribute in their manifest will have to match
one of the Application allowed plugin type names.allowedPluginTypes
- the Map of allowed Plugin typesPluginsManager.setAllowedPluginTypes(java.util.Map)
protected void addAdditionalPluginType(java.lang.String key, AppliManifestType manifestType)
key
- the key to look for in the Plugin ManifestmanifestType
- the type of the application relative to the manifest keyPluginsManager.setAdditionalPluginTypes(java.util.Map)
public void setErrorLogger(ErrorLogger errorLogger)
errorLogger
- the error loggerpublic ErrorLogger getErrorLogger()
getErrorLogger
in interface MDIApplication
public void setDefaultBlockingActions(boolean isBlocking)
setDefaultBlockingActions
in interface MDIApplication
isBlocking
- true if actions are blocking by defaultpublic boolean isDefaultBlockingActions()
isDefaultBlockingActions
in interface MDIApplication
public boolean hasPluginsDirectories()
public boolean hasSinglePluginsDirectory()
public boolean hasPluginsDirectoryList()
protected void setPluginsConfiguration(java.io.File pluginsDir)
pluginsDir
- the directoryprotected void setPluginsConfigurationFile(java.io.File pluginsDir, java.io.File pluginsConfiguration)
pluginsDir
- the plugins directorypluginsConfiguration
- the XML File holding the plugins entry-point classesprotected void setPluginsConfiguration(java.io.File pluginsDir, java.lang.String pluginsConfigFileName)
pluginsDir
- the plugins directorypluginsConfigFileName
- the name of the XML File holding the plugins entry-point classespublic void pluginsActionPerformed(PluginsEvent event)
pluginsActionPerformed
in interface PluginsListener
event
- the PluginsEventprotected void initConfiguration(java.util.prefs.Preferences prefRoot)
pluginsDir
is not null, the application will look for Plugins in this directory. There are two ways of asking the applicatin to load a
Plugin in this directory (Plugins are distributed as jar Files in this directory):
pluginsDefInFile
property is set to true, the application will look for an XML File called pluginsConfiguration
, defining the
Plugin
classes to loadpluginsDefInFile
property is set to false, the application will look for the manifest of the Jar files in this directory, defining the
Plugin
classes to loadprefRoot
- the root Preference, or null if there is no Preference for this MDIApplicationPluginsManager
protected void initConfiguration(java.util.prefs.Preferences prefRoot, short mdiPluginsInitMode)
pluginsDir
is not null, the application will look for Plugins in this directory. There are two ways of asking the application to load
a Plugin in this directory (Plugins are distributed as jar Files in this directory):
pluginsDefInFile
property is set to true, the application will look for an XML File called pluginsConfiguration
, defining the
Plugin
classes to loadpluginsDefInFile
property is set to false, the application will look for the manifest of the Jar files in this directory, defining the
Plugin
classes to loadprefRoot
- the root Preference, or null if there is no Preference for this MDIApplicationmdiPluginsInitMode
- the plugins initialization modePluginsManager
protected abstract ThreadQueue createThreadQueue()
public final ThreadQueue getThreadQueue()
protected void setConfiguration(Configuration conf)
conf
- the application configurationprotected void initConfiguration(java.util.prefs.Preferences prefRoot, java.io.File dir)
prefRoot
- the root Preference, or null if there is no Preference for this MDIApplicationdir
- the reference directory for the configuration. If the directory is null, the default one will be used.initConfiguration(java.util.prefs.Preferences)
,
PluginsManager
protected void initConfiguration(java.util.prefs.Preferences prefRoot, java.io.File dir, short mdiPluginsInitMode)
mdiPluginsInitMode
- the plugins initialization modeprefRoot
- the root Preference, or null if there is no Preference for this MDIApplicationdir
- the reference directory for the configuration. If the directory is null, the default one will be used.initConfiguration(java.util.prefs.Preferences)
,
PluginsManager
public void startTime(MDIAction action)
startTime
in interface MDIApplication
action
- the Actionpublic final long getTime()
getTime
in interface MDIApplication
public long stopTime(MDIAction action)
stopTime
in interface MDIApplication
action
- the Actionpublic void executeAction(MDIAction action, short blockingType)
BlockingType.DEFAULT
: use the default blocking type of the applicationBlockingType.BLOCKING
: if the action should be blockingBlockingType.NOT_BLOCKING
: if the action should not be blockingexecuteAction
in interface MDIApplication
action
- the ActionblockingType
- the enumeration specifying if the action should be blockingpublic void executeAction(MDIAction action, short blockingType, java.lang.ClassLoader loader)
BlockingType.DEFAULT
: use the default blocking type of the applicationBlockingType.BLOCKING
: if the action should be blockingBlockingType.NOT_BLOCKING
: if the action should not be blockingexecuteAction
in interface MDIApplication
action
- the ActionblockingType
- the enumeration specifying if the action should be blockingloader
- the ClassLoader to execute the actionpublic void showActionException(java.lang.String message, java.lang.Exception e)
showActionException
in interface MDIApplication
message
- the message to showe
- the Exceptionprotected void registerPlugins()
public void setCommandLineHandler(CommandLineHandler handler)
setCommandLineHandler
in interface CommandLineListener
handler
- the handlerpublic CommandLineHandler getCommandLineHandler()
getCommandLineHandler
in interface CommandLineListener
public java.util.Map<java.lang.String,java.lang.String> getCommandLineArguments()
getCommandLineArguments
in interface MDIApplication
public void setCommandLineArguments(java.lang.String[] args, boolean keepDash)
args
- the argumentskeepDash
- true if the dash character at the beginning of each argument must be keptpublic void setCommandLineArguments(java.lang.String[] args)
args
- the argumentspublic void setCommandLineArguments(java.util.Map<java.lang.String,java.lang.String> args)
args
- the argumentsprotected void applyCommandLineArguments()
protected void initProcessFromRegister()
public ConfigurationManager getConfigurationManager()
getConfigurationManager
in interface MDIApplication
public PluginsManager getPluginsManager()
getPluginsManager
in interface MDIApplication
public final java.util.List<Plugin> getPlugins()
getPlugins
in interface MDIApplication
public final java.util.Map<java.lang.String,Plugin> getPluginsMap()
getPluginsMap
in interface MDIApplication
public boolean hasPlugin(java.lang.String name)
hasPlugin
in interface MDIApplication
name
- the Plugin namepublic final Plugin getPluginForName(java.lang.String name)
getPluginForName
in interface MDIApplication
name
- the Plugin namepublic final Plugin getPlugin(java.lang.String clazz)
getPlugin
in interface MDIApplication
clazz
- the plugin class pathpublic void addCustomAction(java.lang.String actionName, short customActionType)
actionName
- the custom action namecustomActionType
- the custom action typepublic boolean executeCustomAction(java.lang.String actionName, java.lang.Object... arguments)
actionName
- the custom action namearguments
- the argumentspublic boolean executeCustomAction(java.lang.String actionName, short blockingType, java.lang.Object... arguments)
actionName
- the custom action nameblockingType
- the blocking typearguments
- the argumentsprotected void loadResources()
public void endAction(MDIAction action)
endAction
in interface MDIApplication
action
- the actionpublic void disposeApplication()
disposeApplication
in interface MDIApplication
protected void serializeConfiguration()
public void noWriteMessages()
noWriteMessages
in interface MDIApplication
public void noTimeMessages()
noTimeMessages
in interface MDIApplication