[MOBY-guts] biomoby commit

Paul Gordon gordonp at dev.open-bio.org
Thu Oct 26 00:33:36 UTC 2006


gordonp
Wed Oct 25 20:33:35 EDT 2006
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared
In directory dev.open-bio.org:/tmp/cvs-serv14932/src/main/org/biomoby/shared

Modified Files:
	MobyService.java 
Log Message:
Added method to grab metadata-filled-in service instances
moby-live/Java/src/main/org/biomoby/shared MobyService.java,1.13,1.14
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyService.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyService.java	2006/10/25 02:33:23	1.13
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyService.java	2006/10/26 00:33:35	1.14
@@ -10,6 +10,7 @@
 import java.util.Comparator;
 import java.util.Enumeration;
 import java.util.Vector;
+import org.biomoby.shared.extended.ServiceInstanceParser;
 
 /**
  * A container representing a service. But do not be too excited -
@@ -60,6 +61,10 @@
     public static final int TESTED = 8; // Gives a valid answer to a valid test input provided by the service
     protected int serviceStatus = UNCHECKED;
     protected int statusChecks = UNCHECKED;
+    
+    // We need both, because you can't synchrinize on a null array
+    protected static MobyService[] uninitializedServices = new MobyService[0];
+    protected static MobyService[] services = uninitializedServices;
 
     // the elements of these Vectors are of type MobyData
     protected Vector primaryInputs = new Vector();
@@ -438,4 +443,35 @@
  		this.serviceType = (serviceType == null ? new MobyServiceType() : serviceType);
  	}
 
+    public static MobyService getService(String name, String authority){
+	if(name == null || authority == null){
+	    return null;
+	}
+	
+	// This method has not been called yet in the JVM, populate the datatypes 
+	synchronized (services){
+	    if(services == uninitializedServices){
+		try{
+		    ServiceInstanceParser p = new ServiceInstanceParser("http://biomoby.org/RESOURCES/MOBY-S/ServiceInstances");
+		    services = p.getMobyServicesFromRDF();
+		}
+		catch(Exception e){
+		    System.err.println("Cannot parse MOBY Service Instance Database: " + e);
+		    e.printStackTrace();
+		    return null;
+		}
+	    }
+	}
+
+	// Perform a linear search for the corresponding namespace and authority
+	for(int i = 0; i < services.length; i++){
+	    if(name.equals(services[i].getName()) &&
+	       authority.equals(services[i].getAuthority())){
+		return services[i];
+	    }
+	}
+
+	// Wasn't found if we got to here
+	return null;
+    }
 }




More information about the MOBY-guts mailing list