de.unihalle.informatik.Alida.helpers
Class ALDEnvironmentConfig

java.lang.Object
  extended by de.unihalle.informatik.Alida.helpers.ALDEnvironmentConfig

public class ALDEnvironmentConfig
extends java.lang.Object

Helper class to access environment variables and properties.

This class serves as helper class for reading and writing environment variables and Java environment properties, respectively.

Every Alida operator and also every other class can define properties. To ensure a certain structure of the properties and avoid chaos in property names the properties defined should respect the following convention: alida.operatorname.property The corresponding environment variable will then be ALIDA_OPERATORNAME_PROPERTY following common Unix/Linux conventions.

Author:
moeller

Constructor Summary
ALDEnvironmentConfig()
           
 
Method Summary
static java.lang.String getConfigValue(java.lang.String _operator, java.lang.String _propname)
          Reads the value of the specified property from the environment.
static java.lang.String getConfigValue(java.lang.String _prefix, java.lang.String _operator, java.lang.String _propname)
          Gets the value of a property from the environment.
static java.lang.String getEnvVarValue(java.lang.String _operator, java.lang.String _propname)
          Reads the value of the specified property from environment variables.
static java.lang.String getJVMPropValue(java.lang.String _operator, java.lang.String _propname)
          Reads the value of specified property from JVM properties.
static java.lang.String getJVMPropValue(java.lang.String _prefix, java.lang.String _operator, java.lang.String _propname)
          Reads the value of the specified property from JVM properties.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ALDEnvironmentConfig

public ALDEnvironmentConfig()
Method Detail

getConfigValue

public static java.lang.String getConfigValue(java.lang.String _operator,
                                              java.lang.String _propname)
Reads the value of the specified property from the environment.

Here the default prefix "alida" is assumed. It is combined with the provided operator and environment variable names in this order.

Parameters:
_operator - Name of the operator.
_propname - Name of the property.
Returns:
Value of property, null if not existing.

getConfigValue

public static java.lang.String getConfigValue(java.lang.String _prefix,
                                              java.lang.String _operator,
                                              java.lang.String _propname)
Gets the value of a property from the environment.

Environment properties can be defined in terms of environment variables, or java properties passed to the virtual machine. The options are checked in exactly this order. If the requested property is not found in either of the two configuration environments, null is returned.

The actual name of the property for which the environment is queried is assembled from the specified prefix, the given operator name and the environment variable name (in this order). For checking environment variables all strings are converted to upper-case and linked together by inserting '_' in between. For checking JVM properties, dots are inserted in between and all strings are converted to lower-case.

Parameters:
_prefix - Prefix.
_operator - Name of the operator.
_propname - Name of the property.
Returns:
Value of property, null if not existing.

getEnvVarValue

public static java.lang.String getEnvVarValue(java.lang.String _operator,
                                              java.lang.String _propname)
Reads the value of the specified property from environment variables.

Default prefix is "alida".

Parameters:
_operator - Name of operator, ignored if null.
_propname - Name of the property.
Returns:
Value of property, null if not existing.

getJVMPropValue

public static java.lang.String getJVMPropValue(java.lang.String _operator,
                                               java.lang.String _propname)
Reads the value of specified property from JVM properties.

Default prefix is "alida".

Parameters:
_operator - Name of operator, ignored if null.
_propname - Name of the property.
Returns:
Value of property, null if not existing.

getJVMPropValue

public static java.lang.String getJVMPropValue(java.lang.String _prefix,
                                               java.lang.String _operator,
                                               java.lang.String _propname)
Reads the value of the specified property from JVM properties.

Parameters:
_prefix - Prefix, ignored if null.
_operator - Name of operator, ignored if null.
_propname - Name of the property.
Returns:
Value of property, null if not existing.