| java.lang.Object org.cougaar.bootstrap.SystemProperties
SystemProperties | public class SystemProperties (Code) | | Utility class to access system properties.
|
Method Summary | |
public static void | expandProperties() Expand System properties.
The purpose of the property expansion is to make Java properties
clearer and easier to maintain. | public static void | expandProperties(Properties props) | public static boolean | finalizeProperties() Prevent future calls to
SystemProperties.overrideProperties -- this method
is called early on by the Node. | public static boolean | getBoolean(String name) | public static boolean | getBoolean(String name, boolean deflt) | public static double | getDouble(String name, double deflt) | public static double | getDouble(String name, double deflt, boolean catchFormatError) | public static double | getDouble(String name, double deflt, double parseDeflt) | public static float | getFloat(String name, float deflt) | public static float | getFloat(String name, float deflt, boolean catchFormatError) | public static float | getFloat(String name, float deflt, float parseDeflt) | public static int | getInt(String name, int deflt) | public static int | getInt(String name, int deflt, boolean catchFormatError) | public static int | getInt(String name, int deflt, int parseDeflt) | public static long | getLong(String name, long deflt) | public static long | getLong(String name, long deflt, boolean catchFormatError) | public static long | getLong(String name, long deflt, long parseDeflt) | public static Properties | getProperties() | public static String | getProperty(String name, String deflt) System property getter methods. | public static String | getProperty(String name) | public static Enumeration | getPropertyNames() | public static Properties | getStandardSystemProperties() Returns standard Java properies without the need for write privileges. | public static Properties | getSystemPropertiesWithPrefix(String prefix) Return a Map of system properties.
This method return a Map of all properties that start with the specified
prefix.
Unlike the System.getProperties() method, this method does not require
"write property" privileges.
Parameters: prefix - Used to return property names that start with this specified prefix. | public static synchronized String | getenv(String name) Get an environment variable. | public static void | overrideProperties(Properties props) Replace the System properties with alternate properties.
This method allow us to:
- Define properties in secure environments where System properties
access is restricted, e.g.
| public static String | resolveEnv(String orig_value, boolean windows) Resolve a string like the shell would resolve it, which includes
SystemProperties.resolveVariables and Linux "\" removal. | public static String | resolveVariables(String value, boolean windows, Map env_override, boolean default_to_getenv) Resolve environment variables. | public static Object | setProperty(String name, String value) Set a system property. |
expandProperties | public static void expandProperties()(Code) | | Expand System properties.
The purpose of the property expansion is to make Java properties
clearer and easier to maintain. Use the "${}" tag to introduce
substitutable parameters, so they can be expanded to values
indicated with tag names during property retrieval at runtime.
Properties may be nested as shown in the example below:
a = "foo"
a.subA = "bob"
c = "subA"
b = "${a} ${a.${c}}/smith" => b = "foo bob/smith" after
property expansion.
|
getBoolean | public static boolean getBoolean(String name)(Code) | | |
getBoolean | public static boolean getBoolean(String name, boolean deflt)(Code) | | |
getDouble | public static double getDouble(String name, double deflt)(Code) | | |
getDouble | public static double getDouble(String name, double deflt, boolean catchFormatError)(Code) | | |
getDouble | public static double getDouble(String name, double deflt, double parseDeflt)(Code) | | |
getFloat | public static float getFloat(String name, float deflt)(Code) | | |
getFloat | public static float getFloat(String name, float deflt, boolean catchFormatError)(Code) | | |
getFloat | public static float getFloat(String name, float deflt, float parseDeflt)(Code) | | |
getInt | public static int getInt(String name, int deflt)(Code) | | |
getInt | public static int getInt(String name, int deflt, boolean catchFormatError)(Code) | | |
getInt | public static int getInt(String name, int deflt, int parseDeflt)(Code) | | |
getLong | public static long getLong(String name, long deflt)(Code) | | |
getLong | public static long getLong(String name, long deflt, boolean catchFormatError)(Code) | | |
getLong | public static long getLong(String name, long deflt, long parseDeflt)(Code) | | |
getStandardSystemProperties | public static Properties getStandardSystemProperties()(Code) | | Returns standard Java properies without the need for write privileges.
This method retrieve system properties without requiring write access
privileges (which could be a potential security vulnerability).
|
getSystemPropertiesWithPrefix | public static Properties getSystemPropertiesWithPrefix(String prefix)(Code) | | Return a Map of system properties.
This method return a Map of all properties that start with the specified
prefix.
Unlike the System.getProperties() method, this method does not require
"write property" privileges.
Parameters: prefix - Used to return property names that start with this specified prefix. A Map of system properties. |
getenv | public static synchronized String getenv(String name)(Code) | | Get an environment variable.
This is easy in JDK 1.5, but in JDK 1.4 we need this workaround.
|
overrideProperties | public static void overrideProperties(Properties props)(Code) | | Replace the System properties with alternate properties.
This method allow us to:
- Define properties in secure environments where System properties
access is restricted, e.g. Applets.
- Define properties when multiple Nodes will run in the same JVM.
A possible solution in that environment is to use Classloader-scoped
properties, as in
org.apache.commons.discovery.tools.ManagedProperties
See Also: SystemProperties.finalizeProperties |
resolveEnv | public static String resolveEnv(String orig_value, boolean windows)(Code) | | Resolve a string like the shell would resolve it, which includes
SystemProperties.resolveVariables and Linux "\" removal.
This is a decent approximation that handles the common cases, but it
doesn't handle all the oddities..
|
resolveVariables | public static String resolveVariables(String value, boolean windows, Map env_override, boolean default_to_getenv)(Code) | | Resolve environment variables.
For example, on Linux, this will resolve:
a/$USER/b
to (say):
a/root/b
Parameters: env_override - optional SystemProperties.getenv override map, which canbe null Parameters: default_to_getenv - if a variable is not found in the "env_override"and this parameter is set to true, then look in SystemProperties.getenv |
|
|