org.biomoby.registry.properties
Class RegistryOS
java.lang.Object
org.biomoby.registry.properties.RegistryOS
public class RegistryOS
- extends Object
This class delegates the responisiblity for obtaining system environment
variables to other classes. The classes UNIX.java, Windows.java, etc, all
implement this factory pattern and use the Singleton pattern.
Please note that this class attempts to mimic the functionality that
was inherent in java up until java 1.4 and then brought back in java 5.0.
public class MyOS implements Environment {
public static final MyOS os = new MyOS();
private MyOS() {
}
public Map getEnv() {
// perform os specific code to get environment variables as key,value pairs
// to put in a map
}
public static final void register() {
RegistryOS.register("value obtained using jvm property 'os.name'", os);
}
}
Then just let RegistryOS know about your class, by putting a
MyOS.register();
in the the static block of this class.
To use this class, on any supported OS, do the following:
java.util.Map map = RegistryOS.getEnv();
// lets retrieve the local registries url
String server = (String) map.get("MOBY_SERVER");
- Author:
- Eddie created Nov 28, 2005
RegistryOS
public RegistryOS()
getEnv
public static Map getEnv()
- Returns:
- a java.util.Map object containing the OS environment variables as
key,value pairs
register
public static void register(String key,
Environment value)
- Parameters:
key
- the value obtained by the jvm using the property 'os.name' for
a specific machinevalue
- a java Object that implements Environment.java
Submit a bug or feature
Generated: Sat May 29 04:26:35 EDT 2010