|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eodisp.util.RootApp
public class RootApp
The root application is holds registered application modules and configurations.
As of now there can only be one RootApp instance in one JVM. This instance is
registered with the AppRegistry
at the time an
instance of this class is created. An assertion exception will be thrown if
you try to create two instances of this class.
This class is not thread safe. It is assumed that the
registerXXX
methods are not called concurrently from different
Threads.
Most of the functionality of a Java application should be implemented in separate application modules. Only very few core functionality is directly implemented in this class:
initWorkingDirs(String[])
initLogger(String[])
AppModule
,
Configuration
Nested Class Summary | |
---|---|
static class |
RootApp.RunState
|
Field Summary | |
---|---|
static java.lang.String |
WORKING_DIR_SYSTEM_PROPERTY
|
Constructor Summary | |
---|---|
RootApp(java.lang.String name,
java.lang.String description,
java.io.File defaultWorkingDir,
java.lang.Class mainClass)
Creates a new root application and registers it with the AppManager . |
Method Summary | |
---|---|
void |
execute(java.lang.String[] commandLineArgs)
Executes the root application. |
void |
executeAdditionalAppModules()
|
AppModule |
getAppModule(java.lang.String appModuleId)
|
Configuration |
getConfiguration(java.lang.String configurationId)
Returns the configuration identified by the configuration id parameter. |
java.io.File |
getConfigurationDir()
Returns the standard configuration path for this root application |
java.io.File |
getDataDir()
Returns the standard data path for this root application |
protected java.io.File |
getDefaultWorkingDir()
The default working directory of this root application. |
java.lang.String |
getDescription()
|
java.lang.String |
getName()
|
RootApp.RunState |
getRunState()
Returns the state of this application. |
java.io.File |
getWorkingDir()
The working directory. |
protected void |
initJsap()
Creates the JSAP instance and adds the following options: --help
--working-dir
--delete-lock
|
protected void |
initLogger(java.lang.String[] args)
Initializes the log4j framework |
protected void |
initWorkingDirs(java.lang.String[] args)
Determines the working directory of this root application. |
protected void |
loadConfigurationsFromCommandLine()
Processes the command line arguments. |
protected void |
loadConfigurationsFromFile()
|
void |
registerAppModule(AppModule appModule)
Registers and application module with the root application. |
Configuration |
registerConfiguration(Configuration configuration)
Registers a Configuration. |
Configuration |
registerConfiguration(Configuration configuration,
CommandlineMapper commandlineMapper)
Registers a Configuration with a associated command line mapper. |
Configuration |
registerConfiguration(Configuration configuration,
CommandlineMapper commandlineMapper,
SystemPropertyMapper systemPropertyMapper)
Registers a Configuration with a associated command line mapper and system property mapper. |
void |
shutdown()
Shuts down the root the root application. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String WORKING_DIR_SYSTEM_PROPERTY
Constructor Detail |
---|
public RootApp(java.lang.String name, java.lang.String description, java.io.File defaultWorkingDir, java.lang.Class mainClass)
AppManager
.
defaultWorkingDir
- The default working directory of the root application. The
given file path must be absolute.name
- The name of the application. Used for customizing some of the
help texts. Can be accessed by the application modules and may
be shown to the user.mainClass
- The class that contains the main method from which the JVM was
originally started from. Used for command line usage help
output.Method Detail |
---|
public void execute(java.lang.String[] commandLineArgs)
commandLineArgs
- The arguments given on the command line. Normally this should
be the args
variable from
main( String[] args )
.public void executeAdditionalAppModules()
public void shutdown()
public java.io.File getWorkingDir()
null
)
and only when invoking execute(String[])
it is set. It is unset
(null) after shutting down the root application.
public java.io.File getConfigurationDir()
public java.io.File getDataDir()
protected java.io.File getDefaultWorkingDir()
public void registerAppModule(AppModule appModule)
#execute()
method is invoked.
AppModule#initConfiguration()
public AppModule getAppModule(java.lang.String appModuleId)
public Configuration registerConfiguration(Configuration configuration)
This method must only be called during the configuration initialization
phase, i.e. in implementation of the method
AppModule#initConfiguration()
configuration
- The configuration to be registered. Each configuration
registered must have a distinct id
java.lang.IllegalArgumentException
- if a configuration with the same name is already registered.
java.lang.NullPointerException
- if given configuration is null
public Configuration registerConfiguration(Configuration configuration, CommandlineMapper commandlineMapper)
AppModule.registerConfiguration(RootApp)
configuration
- The configuration to be registered. Each configuration
registered must have a distinct idcommandlineMapper
-
java.lang.IllegalArgumentException
- if a configuration with the same name is already registered.
java.lang.NullPointerException
- if any of the arguments is null
. Use
CommandlineMapper.NULL_COMMAND_LINE_MAPPER
instead of
null
.public Configuration registerConfiguration(Configuration configuration, CommandlineMapper commandlineMapper, SystemPropertyMapper systemPropertyMapper)
The order in which configuration are read is as follows
AppModule#initConfiguration()
configuration
- The configuration to be registered. Each configuration
registered must have a distinct idcommandlineMapper
- systemPropertyMapper
-
java.lang.IllegalArgumentException
- if a configuration with the same name is already registered.
java.lang.NullPointerException
- if any of the arguments is null
. Use
CommandlineMapper.NULL_COMMAND_LINE_MAPPER
and
SystemPropertyMapper.NULL_SYSTEM_PROPERTY_MAPPER
instead of null
.public Configuration getConfiguration(java.lang.String configurationId)
configurationId
- The id of the configuration to be retrieved.
null
if no configuration with the
given name exists.public RootApp.RunState getRunState()
protected void initJsap()
--help
--working-dir
--delete-lock
protected void initWorkingDirs(java.lang.String[] args) throws java.io.IOException
--working-dir
org.eodisp.working-dir
system property
args
-
java.io.IOException
protected void loadConfigurationsFromFile()
protected void initLogger(java.lang.String[] args)
args
- Command line parameters from main
method.protected void loadConfigurationsFromCommandLine()
args
- Command line parameters from main
method.public java.lang.String getName()
public java.lang.String getDescription()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |