com.sap.ip.me.api.conf
Class Configuration

java.lang.Object
  extended bycom.sap.ip.me.api.conf.Configuration

public final class Configuration
extends java.lang.Object

The configuration class offers some methods to read and write properties and to save the configuration.
There are three levels of property sets. The set with the highest priority is the temporary and arguments set. This property set contains all properties that are passed while Mobile Engine startup or are set temporaryly. The next level is the custom property set. The default location of the file that represents this property set is \settings\MobileEngine.config . All properties that are set by the framework or the applications and that should resist after Mobile Engine restart have to use this configuration level. The configuration level with the lowest priority is the default property set. This property set is delivered with the Mobile Engine framework and contains all basic configurations of the Mobile Engine.
The configuration is implemented as a singleton. You can get the instance of the configuration with Configuration.getInstance(). While initialization a set of default properties is loaded. After that the
File.separator + "settings" + File.separator + "MobileEngine.config"
file out of the Mobile Engine installation path will be loaded. For a description of the property keys and their possible values you can see the documentation of the class PropertyKeys.

Author:
SAP
See Also:
PropertyKeys

Method Summary
 boolean getBoolean(java.lang.String key, boolean defaultValue)
          Returns the boolean value for a given key from the configuration.
 java.lang.String getDecodedProperty(java.lang.String key)
          Returns the decoded value for a given key from the configuration.
static java.lang.String getInstallationDirectory()
          Get the installation directory of the Mobile Engine.
static Configuration getInstance()
          Returns the singleton instance of the configuration class.
 java.lang.Object getInstanceForType(java.lang.String key)
          Returns the one and only singleton instance of a class by calling getInstace method that is configured within the Mobile Engine Configuration.
 int getInt(java.lang.String key, int defaultValue)
          Returns the int value for a given key from the configuration.
static java.lang.String getJVMVendorName()
          Gets the java VM vendor name.
 java.util.Vector getKeysWithPrefix(java.lang.String prefix)
          Returns a vector with keys that have the common prefix (given as parameter).
 long getLong(java.lang.String key, long defaultValue)
          Returns the long value for a given key from the configuration.
static java.lang.String getMERuntime()
          Gets the Mobile Engine runtime.
static java.lang.String getOperatingSystemName()
          Gets the operating system name.
 java.lang.String getProperty(java.lang.String key)
          Returns the value for a given key from the configuration.
 java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)
          Returns the value for a given key from the configuration.
static java.lang.String getSettingsFolder()
          Get the settings folder of the Mobile Engine.
 java.lang.Object getSingletonInstanceForType(java.lang.String key)
          Returns the one and only one singleton instance of a class based on key which is configured within the Mobile Engine Configuration.
 void loadConfiguration(java.lang.String configurationFile)
          This method is for framework internal use only.
 void setBoolean(java.lang.String key, boolean value)
          Sets the given property (key-value).
 void setDefaultProperty(java.lang.String key, java.lang.String value)
          Puts the key-value-pair into the user independent configuration (default level).
 void setEncodedProperty(java.lang.String key, java.lang.String value)
          Puts the key-value-pair into the configuration.
 void setInt(java.lang.String key, int value)
          Sets the given property (key-value).
 void setLong(java.lang.String key, long value)
          Sets the given property (key-value).
 void setProperty(java.lang.String key, java.lang.String value)
          Puts the key-value-pair into the configuration (custom configuration level).
 void setTemporary(java.lang.String key, java.lang.String value)
          Puts the key-value-pair into the configuration (temporary level).
 void setTraceInitialized()
           
 void switchUserConfiguration(java.lang.String username)
          This method is for framework internal use only.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setTraceInitialized

public void setTraceInitialized()

getJVMVendorName

public static final java.lang.String getJVMVendorName()
Gets the java VM vendor name.

Returns:
the java VM vendor name.

getOperatingSystemName

public static final java.lang.String getOperatingSystemName()
Gets the operating system name.

Returns:
The operating system name.

getMERuntime

public static final java.lang.String getMERuntime()
Gets the Mobile Engine runtime.

Returns:
The Mobile Engine runtime.

getSettingsFolder

public static final java.lang.String getSettingsFolder()
Get the settings folder of the Mobile Engine. Returns null if not yet initialized. The String ends with a File.separatorChar .

Returns:
The settings folder of the Mobile Engine or null iff not yet initialized.

getInstallationDirectory

public static final java.lang.String getInstallationDirectory()
Get the installation directory of the Mobile Engine. Returns null if not yet initialized. This method returns the same as Configuration.getInstance().getProperty(PropertyKeys.INSTALLATION_DIRECTORY) .

Returns:
The installation directory of the Mobile Engine or null iff installation directory not yet initialized.

getInstance

public static Configuration getInstance()
Returns the singleton instance of the configuration class.

Returns:
The singleton instance of the configuration class.

loadConfiguration

public void loadConfiguration(java.lang.String configurationFile)
This method is for framework internal use only. Do not use this method in your code directly.
The configuration consists of three parts the default configuration, a custom configuration file and the configurations that are set by the start of the Mobile Engine or that are set temporaryly. This method replaces the configurations of the custom configuration file iff the given configuration file can be loaded. Otherwise the old custom configuration set will resist. The Mobile Engine framework loads while startup:
\settings\MobileEngine.config Any exception will be printed to System.err because logging is possibly not initialized yet.

Parameters:
configurationFile - The name of the custom configuration file.

switchUserConfiguration

public void switchUserConfiguration(java.lang.String username)
This method is for framework internal use only. Do not use this method in your code directly.
Switchs the user dependent configuration file.

Parameters:
username - Switches to user specific configuration.

setTemporary

public void setTemporary(java.lang.String key,
                         java.lang.String value)
Puts the key-value-pair into the configuration (temporary level). All configurations that are set with this method will not be saved. They resist as long as the Mobile Engine is running and they have the highest priority.

Parameters:
key - The key must not be null.
value - The value must not be null.

setProperty

public void setProperty(java.lang.String key,
                        java.lang.String value)
Puts the key-value-pair into the configuration (custom configuration level). All configurations that are set with this method will be saved.

Parameters:
key - The key must not be null.
value - The value must not be null.

setDefaultProperty

public void setDefaultProperty(java.lang.String key,
                               java.lang.String value)
Puts the key-value-pair into the user independent configuration (default level). All configurations that are set with this method will be saved.

Parameters:
key - The key must not be null.
value - The value must not be null.

getProperty

public java.lang.String getProperty(java.lang.String key)
Returns the value for a given key from the configuration. The key will be searched first within the temporary property set. If the key was not defined within the temporary properties, the key will be searched within the custom properties and finally within the default properties. If the key is not defined in one of these property sets null will be returned.

Parameters:
key - The key
Returns:
The property value. Returns null if property key was not defined.

getProperty

public java.lang.String getProperty(java.lang.String key,
                                    java.lang.String defaultValue)
Returns the value for a given key from the configuration. If the key was not defined within the configuration, the given default value will be returned. The search order is temporary properties, custom properties and default properties.

Parameters:
key - The key
defaultValue - The default value. Used if key was not defined.
Returns:
The property value
See Also:
getProperty(java.lang.String)

getBoolean

public boolean getBoolean(java.lang.String key,
                          boolean defaultValue)
Returns the boolean value for a given key from the configuration. If the key was not defined within the configuration, the given default value will be returned. The search order is temporary properties, custom properties and default properties.

Parameters:
key - The key
defaultValue - The default value. Used if key was not defined.
Returns:
The property value
See Also:
getProperty(java.lang.String)

setBoolean

public void setBoolean(java.lang.String key,
                       boolean value)
Sets the given property (key-value). The property will be set within the custom property set.

Parameters:
key - The key
value - The boolean value.
See Also:
setProperty(java.lang.String, java.lang.String)

getInt

public int getInt(java.lang.String key,
                  int defaultValue)
Returns the int value for a given key from the configuration. If the key was not defined within the configuration, the given default value will be returned. The search order is temporary properties, custom properties and default properties.

Parameters:
key - The key
defaultValue - The default value. Used if key was not defined.
Returns:
The property value
See Also:
getProperty(java.lang.String)

setInt

public void setInt(java.lang.String key,
                   int value)
Sets the given property (key-value). The property will be set within the custom property set.

Parameters:
key - The key
value - The int value.
See Also:
setProperty(java.lang.String, java.lang.String)

getLong

public long getLong(java.lang.String key,
                    long defaultValue)
Returns the long value for a given key from the configuration. If the key was not defined within the configuration, the given default value will be returned. The search order is temporary properties, custom properties and default properties.

Parameters:
key - The key
defaultValue - The default value. Used if key was not defined.
Returns:
The property value
See Also:
getProperty(java.lang.String)

setLong

public void setLong(java.lang.String key,
                    long value)
Sets the given property (key-value). The property will be set within the custom property set.

Parameters:
key - The key
value - The long value.
See Also:
setProperty(java.lang.String, java.lang.String)

setEncodedProperty

public void setEncodedProperty(java.lang.String key,
                               java.lang.String value)
Puts the key-value-pair into the configuration. Within the configuration the value is encoded. The property will be set within the custom property set.

Parameters:
key - The key
value - The value that should be encoded. If value is null the empty string will be put into the configuration
See Also:
setProperty(java.lang.String, java.lang.String)

getDecodedProperty

public java.lang.String getDecodedProperty(java.lang.String key)
Returns the decoded value for a given key from the configuration.

Parameters:
key - The key
Returns:
The decoded property value. Returns an empty string if property key was not defined.
See Also:
getProperty(java.lang.String)

getKeysWithPrefix

public java.util.Vector getKeysWithPrefix(java.lang.String prefix)
Returns a vector with keys that have the common prefix (given as parameter).

Parameters:
prefix - The prefix for searched keys
Returns:
A vector with keys that have the common prefix.

getSingletonInstanceForType

public java.lang.Object getSingletonInstanceForType(java.lang.String key)
Returns the one and only one singleton instance of a class based on key which is configured within the Mobile Engine Configuration. The value for that key has to be a full qualified class name. If there are any exceptions while creating the instance a FactoryException (RuntimeException) will be thrown.

Parameters:
key - The Configuration key for the class that has to be instantiated.
Returns:
The instance of the class that is configured within the Mobile Engine Configuration for the key that was provided by the import parameter.
See Also:
FactoryException

getInstanceForType

public java.lang.Object getInstanceForType(java.lang.String key)
Returns the one and only singleton instance of a class by calling getInstace method that is configured within the Mobile Engine Configuration. The value for that key has to be a full qualified class name. If there are any exceptions while creating the instance a FactoryException (RuntimeException) will be thrown.

Parameters:
key - The Configuration key for the class that has to be instantiated.
Returns:
The instance of the class that is configured within the Mobile Engine Configuration for the key that was provided by the import parameter.
See Also:
FactoryException


Copyright © 2005 SAP AG. All Rights Reserved.