Version: 1.1.1

org.biomoby.registry.properties
Class RegistryOS

java.lang.Object
  extended by 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

Constructor Summary
RegistryOS()
           
 
Method Summary
static Map getEnv()
           
static void register(String key, Environment value)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RegistryOS

public RegistryOS()
Method Detail

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 machine
value - a java Object that implements Environment.java

Version: 1.1.1

Submit a bug or feature
Generated: Sat May 29 04:26:35 EDT 2010