Openwings API Documentation (v1.1)

net.openwings.identity
Class PropertyInitializer

java.lang.Object
  extended bynet.openwings.identity.PropertyInitializer

public final class PropertyInitializer
extends java.lang.Object

This class is a utility for setting system properties. The main motivation for this command is to allow more properties to be set than could be successfully set on the Java command line alone (i.e. due to string length). This class is a static singleton that should be invoked prior to reading system properties. It will try to get the property file to read from a PROPERTY_FILE_PROPERTY. If that is unsuccessful it will attempt to load properties from the DEFAULT_PROPERTY_FILE.

Properties read in may contain references to other properties and methods in the following form:

For method invocations, the class must be loaded off of the classpath. The method must take no parameters and return a string. This substitution only occurs when the initializer is called. This handles both static and non-static methods.

Property file inclusion is also supported using the built in property file comment syntax:

Where <myfile> can be a local file. Included property files will be processed first in order of occurence. Then the main file will be processed. Forward references are supported for the set of properties read in, other system properties are not resolved. Circular dependencies are not detected, but a built-in safety measure will prevent dependencies from being resolved beyond MAX_DEPENDENCY_DEPTH.


Field Summary
static java.lang.String DEFAULT_PROPERTY_FILE
          This constant denotes the default property file name.
static java.lang.String FILE_INCLUDE
          This constant denotes a file inclusion
static int MAX_DEPENDENCY_DEPTH
          This constant represents the maximum number of references to follow when resolving dependencies.
static java.lang.String PROPERTY_FILE_PROPERTY
          This constant denotes the property name used to get the properties file.
static java.lang.String REFERENCE_BEGIN
          This constant denotes the beginning of a reference.
static java.lang.String REFERENCE_END
          This constant denotes the ending of a reference.
static char REFERENCE_METHOD
          This constant denotes a method reference.
 
Method Summary
static java.lang.String getHost()
          This method is a convenience function for getting the hostname in a property file.
static void initialize()
          This method is used to set properties from a property file.
static void main(java.lang.String[] args)
          This main is for testing purposes only.
static java.lang.String translate(java.lang.String target)
          This method can be used to translate strings containing property or method references.
static java.lang.String translate(java.lang.String target, java.util.Properties properties)
          This method can be used to translate strings containing property or method references.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_FILE_PROPERTY

public static final java.lang.String PROPERTY_FILE_PROPERTY
This constant denotes the property name used to get the properties file.

See Also:
Constant Field Values

DEFAULT_PROPERTY_FILE

public static final java.lang.String DEFAULT_PROPERTY_FILE
This constant denotes the default property file name.

See Also:
Constant Field Values

REFERENCE_BEGIN

public static final java.lang.String REFERENCE_BEGIN
This constant denotes the beginning of a reference.

See Also:
Constant Field Values

REFERENCE_END

public static final java.lang.String REFERENCE_END
This constant denotes the ending of a reference.

See Also:
Constant Field Values

REFERENCE_METHOD

public static final char REFERENCE_METHOD
This constant denotes a method reference.

See Also:
Constant Field Values

FILE_INCLUDE

public static final java.lang.String FILE_INCLUDE
This constant denotes a file inclusion

See Also:
Constant Field Values

MAX_DEPENDENCY_DEPTH

public static final int MAX_DEPENDENCY_DEPTH
This constant represents the maximum number of references to follow when resolving dependencies.

See Also:
Constant Field Values
Method Detail

translate

public static java.lang.String translate(java.lang.String target)
This method can be used to translate strings containing property or method references. Typically the initialize method should have been called sometime before this.

Parameters:
target - string to be translated
Returns:
the string with references resolved, if resolvable

translate

public static java.lang.String translate(java.lang.String target,
                                         java.util.Properties properties)
This method can be used to translate strings containing property or method references. Typically the initialize method should have been called sometime before this.

Parameters:
target - string to be translated
Returns:
the string with references resolved, if resolvable

initialize

public static void initialize()
This method is used to set properties from a property file. It will only attempt to read the file once over all invocations.


getHost

public static java.lang.String getHost()
This method is a convenience function for getting the hostname in a property file. When the following reference is used in a property: $, the reference will be replaced with the local host name

Returns:
the local host name

main

public static void main(java.lang.String[] args)
This main is for testing purposes only. It displays the system properties before and after adding the new properties.


Openwings API Documentation (v1.1)