org.openbp.common.application
Class Application

java.lang.Object
  extended by org.openbp.common.application.Application

public final class Application
extends java.lang.Object

This class manages the name and root directory of an application. Because other parts of the framework and applications built on top of it rely on this setting, the class should be initialized by a call to initialize() as soon as possible.

Author:
Heiko Erhardt

Field Summary
static java.lang.String ROOTDIR_PROVIDER
          Root directory name
static java.lang.String SYSTEM_PROVIDER
          System provider name
 
Method Summary
static void defineRootDirSettingName(java.lang.String name)
          Defines one of the names under which the root directory should appear in the SettingUtil.
static java.lang.String getAppName()
          Deprecated. Application name functionality has been removed
static java.lang.String[] getArguments()
          Gets the command line arguments.
static java.lang.String getRootDir()
          Gets the root dir.
static void initialize()
          Sets resource and Log4j property file locations according to the application name and root dir.
protected static void initializeRootDir()
          Initializes the root directory from the argument list or the system properties if not set yet.
protected static void initializeSettingProvidersAndLogger()
          Sets up the default providers of the setting manager.
static void registerPropertyResource(java.lang.String resourceName, int priority, boolean writeable)
          Registers a property file resource.
static void setAppName(java.lang.String appNameArg)
          Deprecated. Application name functionality has been removed
static void setArguments(java.lang.String[] argumentsArg)
          Sets the command line arguments.
static void setNameAndArguments(java.lang.String name, java.lang.String[] args)
          Deprecated. Application name functionality has been removed; use setArguments(java.lang.String[]) instead
static void setRootDir(java.lang.String rd)
          Sets the default root dir of the application.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SYSTEM_PROVIDER

public static final java.lang.String SYSTEM_PROVIDER
System provider name

See Also:
Constant Field Values

ROOTDIR_PROVIDER

public static final java.lang.String ROOTDIR_PROVIDER
Root directory name

See Also:
Constant Field Values
Method Detail

setNameAndArguments

public static void setNameAndArguments(java.lang.String name,
                                       java.lang.String[] args)
Deprecated. Application name functionality has been removed; use setArguments(java.lang.String[]) instead

Sets the application name and the application arguments.

Parameters:
name - Name of the application (defines resource sub directory)
args - Command line arguments

initialize

public static void initialize()
Sets resource and Log4j property file locations according to the application name and root dir.


initializeRootDir

protected static void initializeRootDir()
Initializes the root directory from the argument list or the system properties if not set yet.


initializeSettingProvidersAndLogger

protected static void initializeSettingProvidersAndLogger()
Sets up the default providers of the setting manager. This method will add the SystemPropertyProvider using the name "system" and priority 100 and an PropertyFileProvider that accesses the specified property file as read-only provider using the name "core" and priority 90.


registerPropertyResource

public static void registerPropertyResource(java.lang.String resourceName,
                                            int priority,
                                            boolean writeable)
Registers a property file resource.

Parameters:
resourceName - Resource name
priority - Setting resource provider priority to use
writeable - true if this is a writable resource; In this case, the properties will be saved back to the property resource if changed. Note that the resource must be writable (i. e. a property file).

getAppName

public static java.lang.String getAppName()
Deprecated. Application name functionality has been removed

Gets the application name.


setAppName

public static void setAppName(java.lang.String appNameArg)
Deprecated. Application name functionality has been removed

Sets the application name.


getArguments

public static java.lang.String[] getArguments()
Gets the command line arguments.


setArguments

public static void setArguments(java.lang.String[] argumentsArg)
Sets the command line arguments.


getRootDir

public static java.lang.String getRootDir()
Gets the root dir.

Returns:
The root directory of the application or the current directory if the root directory cannot be determined.

setRootDir

public static void setRootDir(java.lang.String rd)
Sets the default root dir of the application. The method will print out an error message and exit the program if the root directory is not accessible.

Parameters:
rd - Root directory

defineRootDirSettingName

public static void defineRootDirSettingName(java.lang.String name)
Defines one of the names under which the root directory should appear in the SettingUtil. Do not call before initialize()().

Parameters:
name - Name to add


Copyright © 2011. All Rights Reserved.