Package com.iplanet.am.util
Class SystemProperties
java.lang.Object
com.iplanet.am.util.SystemProperties
This class provides functionality that allows single-point-of-access to all
related system properties.
The system properties can be set in couple of ways: programmatically by
calling the initializeProperties
method, or can be statically
loaded at startup from a file named:
AMConfig.[class,properties]
.
Setting the properties through the API takes precedence and will replace the
properties loaded via file. For statically loading the properties via a file,
this class tries to first find a class, AMConfig.class
, and
then a file, AMConfig.properties
in the CLASSPATH accessible
to this code. The AMConfig.class
takes precedence over the
flat file AMConfig.properties
.
If multiple servers are running, each may have their own configuration file.
The naming convention for such scenarios is
AMConfig-<serverName>
.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
This method lets you query for a system property whose value is same asString
key.static String
This method lets you query for a system property whose value is same asString
key.static Properties
getAll()
This method lets you get all the properties defined and their values.static boolean
getAsBoolean
(String key) Returns the property value as a booleanstatic boolean
getAsBoolean
(String key, boolean defaultValue) Returns the property value as a booleanstatic int
static long
Parses a system property as a set of strings by splitting the value on white space characters.Parses a system property as a set of strings by splitting the value on the given delimiter expression.Parses a system property as a set of strings by splitting the value on the given delimiter expression.Returns the property name to service attribute schema name mapping.static String
static Properties
Deprecated.static Properties
Returns all the properties defined and their values.static String
Returns the server instance name of which properties are retrieved to initialized this object.static void
initializeProperties
(String file) Initializes properties bundle from thefile
passed.static void
initializeProperties
(String propertyName, String propertyValue) Initializes a property to be used by OpenAM.static void
initializeProperties
(Properties properties) static void
initializeProperties
(Properties properties, boolean reset) Initializes the properties to be used by OpenAM.static void
initializeProperties
(Properties properties, boolean reset, boolean withDefaults) Initializes the properties to be used by OpenAM.static boolean
Returnstrue
if instance is running in server mode.static long
Returns a counter for last modification.static void
Listen for runtime changes to a system property value.static String
replaceServerUriPlaceholder
(String line, String value) Deal with the special case where OpenAM is deployed at the ROOT context so that lines containing the %SERVER_URI% placeholder are properly handled.static void
setServerInstanceName
(String name) Sets the server instance name of which properties are retrieved to initialized this object.
-
Field Details
-
CONFIG_PATH
Runtime flag to be set, in order to override the path of the configuration file.- See Also:
-
CONFIG_FILE_NAME
Default name of the configuration file.- See Also:
-
PROPERTIES
New configuration file extension- See Also:
-
-
Constructor Details
-
SystemProperties
public SystemProperties()
-
-
Method Details
-
get
This method lets you query for a system property whose value is same asString
key. The method first tries to read the property from java.lang.System followed by a lookup in the config file.- Parameters:
key
- typeString
, the key whose value one is looking for.- Returns:
- the value if the key exists; otherwise returns
null
-
replaceServerUriPlaceholder
Deal with the special case where OpenAM is deployed at the ROOT context so that lines containing the %SERVER_URI% placeholder are properly handled.- Parameters:
line
- String the line to replace occurrences of the %SERVER_URI% placeholder.value
- String the value to use in place of the %SERVER_URI% placeholder.- Returns:
- A string based on line with any %SERVER_URI% placeholders replaced with value.
-
get
This method lets you query for a system property whose value is same asString
key.- Parameters:
key
- the key whose value one is looking for.def
- the default value if the key does not exist.- Returns:
- the value if the key exists; otherwise returns default value.
-
getAsBoolean
Returns the property value as a boolean- Parameters:
key
- the key whose value one is looking for.- Returns:
- the boolean value if the key exists; otherwise returns false
-
getAsBoolean
Returns the property value as a boolean- Parameters:
key
- the property name.defaultValue
- value if key is not found.- Returns:
- the boolean value if the key exists; otherwise the default value
-
getAsInt
- Parameters:
key
- The System Property key to lookup.defaultValue
- If the property was not set, or could not be parsed to an int.- Returns:
- Either the defaultValue, or the numeric value assigned to the System Property.
-
getAsLong
- Parameters:
key
- The System Property key to lookup.defaultValue
- If the property was not set, or could not be parsed to a long.- Returns:
- Either the defaultValue, or the numeric value assigned to the System Property.
-
getAsSet
Parses a system property as a set of strings by splitting the value on the given delimiter expression.- Parameters:
key
- The System Property key to lookup.delimiterRegex
- The regular expression to use to split the value into elements in the set.defaultValue
- The default set to return if the property does not exist.- Returns:
- the value of the property parsed as a set of strings.
-
getAsSet
Parses a system property as a set of strings by splitting the value on the given delimiter expression.- Parameters:
key
- The System Property key to lookup.delimiterRegex
- The regular expression to use to split the value into elements in the set.- Returns:
- the value of the property parsed as a set of strings or an empty set if no match is found.
-
getAsSet
Parses a system property as a set of strings by splitting the value on white space characters.- Parameters:
key
- The System Property key to lookup.- Returns:
- the value of the property parsed as a set of strings or an empty set if no match is found.
-
getProperties
Returns all the properties defined and their values. This is a defensive copy of the properties and so updates to the returned object will not be reflected in the actual properties used by OpenAM.- Returns:
- Properties object with a copy of all the key value pairs.
-
getAll
This method lets you get all the properties defined and their values. The method first tries to load the properties from java.lang.System followed by a lookup in the config file.- Returns:
- Properties object with all the key value pairs.
-
getPlatform
Deprecated.usegetAll()
This method lets you query for all the platform properties defined and their values. Returns a Properties object with all the key value pairs.- Returns:
- the platform properties
-
initializeProperties
Initializes properties bundle from thefile
passed.- Parameters:
file
- typeString
, file name for the resource bundle- Throws:
MissingResourceException
- If the resource bundle cannot be found.
-
initializeProperties
-
initializeProperties
Initializes the properties to be used by OpenAM. Ideally this must be called first before any other method is called within OpenAM. This method provides a programmatic way to set the properties, and will override similar properties if loaded for a properties file.- Parameters:
properties
- properties for OpenAMreset
-true
to reset existing properties.
-
initializeProperties
Initializes the properties to be used by OpenAM. Ideally this must be called first before any other method is called within OpenAM. This method provides a programmatic way to set the properties, and will override similar properties if loaded for a properties file.- Parameters:
properties
- properties for OpenAM.reset
-true
to reset existing properties.withDefaults
-true
to include default properties.
-
initializeProperties
Initializes a property to be used by OpenAM. Ideally this must be called first before any other method is called within OpenAM. This method provides a programmatic way to set a specific property, and will override similar property if loaded for a properties file.- Parameters:
propertyName
- property name.propertyValue
- property value.
-
lastModified
public static long lastModified()Returns a counter for last modification. The counter is incremented if the properties are changed by calling the following methodinitializeProperties
. This is a convenience method for applications to track changes to OpenAM properties.- Returns:
- counter of the last modification
-
setServerInstanceName
Sets the server instance name of which properties are retrieved to initialized this object.- Parameters:
name
- Server instance name.
-
getServerInstanceName
Returns the server instance name of which properties are retrieved to initialized this object.- Returns:
- Server instance name.
-
isServerMode
public static boolean isServerMode()Returnstrue
if instance is running in server mode.- Returns:
true
if instance is running in server mode.
-
getConfigPath
-
getAttributeMap
Returns the property name to service attribute schema name mapping.- Returns:
- Property name to service attribute schema name mapping.
-
observe
public static void observe(com.sun.identity.common.configuration.ConfigurationListener listener, String... properties) Listen for runtime changes to a system property value. Only values that are stored in the SMS will be changed at runtime. Seeserverdefaults.properties
,amPlatform.xml
andserverAttributeMap.properties
.- Parameters:
listener
- The listener to call when one of the provided properties has changed.properties
- The list of properties that should be observed. A change in any one of these properties will cause the listener to be notified.
-
getAll()