com.groiss.component
Class Configuration

java.lang.Object
  extended by com.groiss.component.Configuration

public class Configuration
extends Object

This class handles the access to the configuration. There are two types of configurations: the configuration of @enterprise and the configuration of the applications. On startup @enterprise reads the configuration files and keeps the contents in memory. For access to the system configuration use Configuration.get(). For accessing the configuration of an application use Configuration.get("appl-id").

A configuration object contains the map between parameter names and values.


Field Summary
static String OBFUSCATED_PREFIX
           
 
Method Summary
 void addParameterGroup(String s)
           
static Configuration create(String id)
          Add a configuration to the internal map of configurations.
static String demansch(String arg)
          Deprecated. 
static Configuration get()
          Return the @enterprise configuration.
static Configuration get(String id)
          Get the configuration by the given id.
 Boolean getBoolean(String name)
          Return the property value as Boolean.
 Class<?> getClass(String name)
          Return the property value as class.
static Map<String,Configuration> getConfigurations()
          Return the whole map of configurations.
 Element getDefinition()
          Return the definition of a configuration.
 Double getDouble(String name)
          Return the property value as Double.
 String getFileName()
          Return the file name the configuration is loaded from.
 Float getFloat(String name)
          Return the property value as Float.
 String getId()
          Return the id of this configuration.
 Integer getInt(String name)
          Return the property value as Integer.
 Long getLong(String name)
          Return the property value as Long.
 Object getObject(String name)
          Return the property value.
 String getPasswordProperty(String name)
          Get the value of a "mangled" property.
 Properties getProperties()
          Return the whole paramter map.
 String getProperty(String name)
          Returns the value of the property with the given name.
 String getProperty(String name, String defValue)
          Deprecated. define default values in the xml decsription of the configuration.
 Resource getResource()
          Rerturn the resource for this configuration.
 Class getType(String name)
          Return the type of the given property.
 boolean isPasswordProperty(String name)
           
static void loadTopLevel(String filename)
          Load the main configuration.
static String mansch(String arg)
          Deprecated. 
 boolean needsRestart(String param)
          Returns true if the property change needs a server restart to become effective.
 void reload()
          Reload the configuration from the configured file.
static String saveConvert(String theString, boolean escapeSpace)
           
 void setFileName(String filename)
          Set the file name for the configuration.
 void setProperty(String name, Object value)
          Set a property to a value.
 void setProperty(String name, String value)
          Set a property to a value.
 void setPropFile(String url)
          Set the url for the description file for the configuration.
 void setResource(Resource res)
          Set a resource for internationalization of this configuration.
 void setSystemProps()
          Copy all properties of this configuration into the system properties.
 void setVisibility(String paramGroupId, boolean visible)
          Set the visibility of a parameter group in the configuration
 void store()
          Save the configuration on the file system
static void storeProps(Properties props, File file)
           
static String valToString(Object value)
          Convert a value from the configuration to a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OBFUSCATED_PREFIX

public static final String OBFUSCATED_PREFIX
See Also:
Constant Field Values
Method Detail

create

public static Configuration create(String id)
Add a configuration to the internal map of configurations. This is called on startup for the system configuration and the application configurations.

Parameters:
id - the id of the application
Returns:
a new Configuration object

get

public static Configuration get(String id)
Get the configuration by the given id.

Parameters:
id - the id of the configuration, normally the id of an application.
Returns:
a Configuration object

getConfigurations

public static Map<String,Configuration> getConfigurations()
Return the whole map of configurations.

Returns:
a map

get

public static Configuration get()
Return the @enterprise configuration.

Returns:
the configuration object.

setResource

public void setResource(Resource res)
Set a resource for internationalization of this configuration. The resource of the application configuration objects is set to the application resource on startup.

Parameters:
res - a resource object

getResource

public Resource getResource()
Rerturn the resource for this configuration.

Returns:
a resource or null if none is set.

setVisibility

public void setVisibility(String paramGroupId,
                          boolean visible)
Set the visibility of a parameter group in the configuration

Parameters:
paramGroupId - the id of the group
visible - the new visibility

getDefinition

public Element getDefinition()
Return the definition of a configuration.

Returns:
the root node of the definition as JDOM Element

setPropFile

public void setPropFile(String url)
Set the url for the description file for the configuration.

Parameters:
url -

addParameterGroup

public void addParameterGroup(String s)
Parameters:
s -

needsRestart

public boolean needsRestart(String param)
Returns true if the property change needs a server restart to become effective.

Parameters:
param - name of the property
Returns:
true if restart is necessary

reload

public void reload()
            throws IOException
Reload the configuration from the configured file.

Throws:
IOException

loadTopLevel

public static void loadTopLevel(String filename)
                         throws IOException,
                                FileNotFoundException
Load the main configuration.

Throws:
IOException
FileNotFoundException

setSystemProps

public void setSystemProps()
Copy all properties of this configuration into the system properties.


getFileName

public String getFileName()
Return the file name the configuration is loaded from.

Returns:
a path name

setFileName

public void setFileName(String filename)
Set the file name for the configuration. The file name is used when the configuration is stored.

Parameters:
filename -

getId

public String getId()
Return the id of this configuration.

Returns:
a string

getProperty

public String getProperty(String name)
Returns the value of the property with the given name. If there is no property with this name the method returns null. If the property value is not of type string the method toString() is called on it.

Parameters:
name - name of a property
Returns:
the value

getProperty

@Deprecated
public String getProperty(String name,
                                     String defValue)
Deprecated. define default values in the xml decsription of the configuration.

Returns the value of the specified configuration key or the defValue, if the configuration entry is not found.

Parameters:
name - the configuration entry key
defValue - the default value
Returns:
the value of the specified configuration key or the defValue, if the configuration entry is not found.

getBoolean

public Boolean getBoolean(String name)
Return the property value as Boolean.

Parameters:
name - the name of the property
Returns:
the value casted to Boolean

getInt

public Integer getInt(String name)
Return the property value as Integer.

Parameters:
name - the name of the property
Returns:
the value casted to Integer

getLong

public Long getLong(String name)
Return the property value as Long.

Parameters:
name - the name of the property
Returns:
the value casted to Long

getFloat

public Float getFloat(String name)
Return the property value as Float.

Parameters:
name - the name of the property
Returns:
the value casted to Float

getDouble

public Double getDouble(String name)
Return the property value as Double.

Parameters:
name - the name of the property
Returns:
the value casted to Double

getClass

public Class<?> getClass(String name)
Return the property value as class.

Parameters:
name - the name of the property
Returns:
the value casted to Class

getObject

public Object getObject(String name)
Return the property value.

Parameters:
name - the name of the property
Returns:
the value without any conversion

setProperty

public void setProperty(String name,
                        String value)
Set a property to a value.

Parameters:
name - the name of the property
value - the value string

setProperty

public void setProperty(String name,
                        Object value)
Set a property to a value.

Parameters:
name - the name of the property
value - the value object

isPasswordProperty

public boolean isPasswordProperty(String name)

getPasswordProperty

public String getPasswordProperty(String name)
Get the value of a "mangled" property.

Parameters:
name -
Returns:
the plain value

getType

public Class getType(String name)
Return the type of the given property.

Parameters:
name - the name of the property
Returns:
the type

store

public void store()
Save the configuration on the file system


storeProps

public static void storeProps(Properties props,
                              File file)

valToString

public static String valToString(Object value)
Convert a value from the configuration to a string. The method converts null to the empty string, returns the classname for classes and calls toString() to all other values. Moreover it calls trim() on the result.

Parameters:
value - an object
Returns:
a string representation of a configuration value

mansch

@Deprecated
public static String mansch(String arg)
Deprecated. 

This method makes a string unreadable. Is is used to store passwords in a configuration file. It is not an encryption but is much better than storing the value unchanged.


demansch

@Deprecated
public static String demansch(String arg)
Deprecated. 

Inverse function to mansch.


getProperties

public Properties getProperties()
Return the whole paramter map.

Returns:
a Properties object

saveConvert

public static String saveConvert(String theString,
                                 boolean escapeSpace)


@enterprise 8.0.10078 Copyright © 2001-2011 Groiss Informatics GmbH. All Rights Reserved.