[MOBY-guts] biomoby commit

Eddie Kawas kawas at dev.open-bio.org
Wed Oct 11 01:54:50 UTC 2006


kawas
Tue Oct 10 21:54:50 EDT 2006
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/properties
In directory dev.open-bio.org:/tmp/cvs-serv25229/Java/src/main/org/biomoby/registry/properties

Modified Files:
	WindowsNT.java Windows.java UNIX.java RegistryOS.java 
	MobyProperties.java MobyCentralConfig.java 
Log Message:

moby-live/Java/src/main/org/biomoby/registry/properties WindowsNT.java,1.2,1.3 Windows.java,1.1,1.2 UNIX.java,1.1,1.2 RegistryOS.java,1.1,1.2 MobyProperties.java,1.4,1.5 MobyCentralConfig.java,1.4,1.5
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/properties/WindowsNT.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/properties/WindowsNT.java	2006/04/20 15:10:44	1.2
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/properties/WindowsNT.java	2006/10/11 01:54:50	1.3
@@ -12,6 +12,7 @@
  * 
  * @author Eddie created Nov 28, 2005
  */
+ at SuppressWarnings("unchecked")
 public class WindowsNT implements Environment {
 
 	/**

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/properties/Windows.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/properties/Windows.java	2005/11/29 23:06:24	1.1
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/properties/Windows.java	2006/10/11 01:54:50	1.2
@@ -12,6 +12,7 @@
  * 
  * @author Eddie created Nov 28, 2005
  */
+ at SuppressWarnings("unchecked")
 public class Windows implements Environment {
 
 	/**

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/properties/UNIX.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/properties/UNIX.java	2005/11/29 23:06:24	1.1
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/properties/UNIX.java	2006/10/11 01:54:50	1.2
@@ -12,6 +12,7 @@
  * 
  * @author Eddie created Nov 28, 2005
  */
+ at SuppressWarnings("unchecked")
 public class UNIX implements Environment {
 	/**
 	 * the singleton

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/properties/RegistryOS.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/properties/RegistryOS.java	2005/11/29 23:06:24	1.1
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/properties/RegistryOS.java	2006/10/11 01:54:50	1.2
@@ -48,6 +48,7 @@
  * 
  * @author Eddie created Nov 28, 2005
  */
+ at SuppressWarnings("unchecked")
 public class RegistryOS {
 	// factory pattern
 	private static java.util.HashMap storage = new java.util.HashMap();

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/properties/MobyProperties.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/properties/MobyProperties.java	2006/01/03 19:25:59	1.4
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/properties/MobyProperties.java	2006/10/11 01:54:50	1.5
@@ -42,6 +42,7 @@
  * <p>For questions, comments, or bugs
  * <p>email me at edward.kawas at gmail.com
  */
+ at SuppressWarnings("unchecked")
 public class MobyProperties {
     private static Properties properties = new Properties();
     
@@ -53,15 +54,17 @@
      * @return A Properties object with either the properties obtained from the environment or an empty map.
      */
     public final static Properties PROPERTIES() {
-        Map map = RegistryOS.getEnv();
-        //
+        Map map = new HashMap();
+        // 
         if (System.getProperty("MOBY_CENTRAL_CONFIG") != null && !System.getProperty("MOBY_CENTRAL_CONFIG").equals(""))
         	map.put("MOBY_CENTRAL_CONFIG" , System.getProperty("MOBY_CENTRAL_CONFIG"));
         if (System.getProperty("MOBY_SERVER") != null && !System.getProperty("MOBY_SERVER").equals(""))
         	map.put("MOBY_SERVER" , System.getProperty("MOBY_SERVER"));
         if (System.getProperty("MOBY_URI") != null && !System.getProperty("MOBY_URI").equals(""))
         	map.put("MOBY_URI" , System.getProperty("MOBY_URI"));
-        properties.putAll(map);
+        // did we fail to populate the map?
+        if (map.isEmpty())
+        	properties.putAll(RegistryOS.getEnv());
         return properties;
     }
     

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/properties/MobyCentralConfig.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/properties/MobyCentralConfig.java	2005/12/02 20:40:18	1.4
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/properties/MobyCentralConfig.java	2006/10/11 01:54:50	1.5
@@ -15,6 +15,9 @@
 import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.biomoby.shared.MobyException;
 
 /**
@@ -25,12 +28,15 @@
  * <p>For questions, comments, or bugs
  * <p>email me at edward.kawas at gmail.com
  */
+ at SuppressWarnings("unchecked")
 public class MobyCentralConfig {
 
-    private final static String location = MobyProperties.PROPERTIES().getProperty("MOBY_CENTRAL_CONFIG"); //use the environment variables you set with your own registry
+    private static Log log = LogFactory.getLog(MobyCentralConfig.class);
+    
+    private final static String location = getLocation();
 
     private final static String regexp = "^(\\w+)\\s*=\\s*(.*)$";
-
+   
     /**
      * A method that retrieves the mySQL connection details for the database mobycentral. 
      * <p><b>PRE:</b> The property config is specified and configured correctly in the file biomoby.properties.
@@ -45,7 +51,19 @@
         return map;
     }
 
-    /**
+    private static String getLocation() {
+    	if (System.getProperty("MOBY_CENTRAL_CONFIG")==null) {
+    		log.debug("getting MOBY_CENTRAL_CONFIG using MobyProperties()");
+    		return MobyProperties.PROPERTIES().getProperty("MOBY_CENTRAL_CONFIG");
+    	}
+    	else {
+    		// use the environment variables you set with your own registry
+    		log.debug("getting MOBY_CENTRAL_CONFIG using System.getProperty()");
+    		return System.getProperty("MOBY_CENTRAL_CONFIG"); 
+    	}
+	}
+
+	/**
      * A method that retrieves the mySQL connection details for the database mobynamespace. 
      * <p><b>PRE:</b> The property config is specified and configured correctly in the file biomoby.properties.
      * <p><b>POST:</b> Map consists of the mySQL connection information for the database mobynamespace or MobyException is thrown.
@@ -105,9 +123,8 @@
             throws MobyException {
     	if (location == null)
     		throw new MobyException(
-                    "Error - "
-                            + location
-                            + " environment variable found. Make sure that MOBY_CENTRAL_CONFIG is set correctly in the environment");
+                    "Error - MOBY_CENTRAL_CONFIG ==  null;"
+                            + " Make sure that MOBY_CENTRAL_CONFIG is set correctly in the environment");
         File file = new File(location);
         BufferedReader br = null;
         try {




More information about the MOBY-guts mailing list