[MOBY-guts] biomoby commit

Paul Gordon gordonp at dev.open-bio.org
Mon Dec 17 18:31:09 UTC 2007


gordonp
Mon Dec 17 13:31:09 EST 2007
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/service
In directory dev.open-bio.org:/tmp/cvs-serv5925/src/main/org/biomoby/service

Modified Files:
	MobyServlet.java mobyService.java 
Log Message:
Added support for non-default registry usage for MobyServlet's
moby-live/Java/src/main/org/biomoby/service MobyServlet.java,1.9,1.10 mobyService.java,1.2,1.3
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/MobyServlet.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/MobyServlet.java	2007/12/14 16:27:28	1.9
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/MobyServlet.java	2007/12/17 18:31:09	1.10
@@ -3,6 +3,7 @@
 import org.biomoby.service.test.TestServletConfig;
 import org.biomoby.service.test.TestServletContext;
 
+import org.biomoby.registry.meta.Registry;
 import org.biomoby.shared.*;
 import org.biomoby.shared.data.*;
 import org.biomoby.shared.parser.*;
@@ -69,12 +70,14 @@
     protected static Name stringEncAttrName;
     protected final static String stringEncAttrValue = "xsd:string";
     protected static Name faultName;
+    protected static Registry registry; 
 
     protected MobyService thisService;
     protected MobyContentInstance currentContent = null;
     protected boolean isInitialized = false;
     /** Changing this value makes logging more or less verbose */
     protected boolean isDebug = false;
+    /** Where data type, namespace and service type definition come from, if null, the default registry is used */
 
     public void doGet(HttpServletRequest request,
 		      HttpServletResponse response)
@@ -275,7 +278,7 @@
 									    null, 
 									    null);
 	
-	mobyRequestContents = MobyDataUtils.fromXMLDocument(mobyEnvelopeDOM); 
+	mobyRequestContents = MobyDataUtils.fromXMLDocument(mobyEnvelopeDOM, registry); 
 
 	return mobyRequestContents;
     }
@@ -621,16 +624,29 @@
 					       "", 
 					       SOAPConstants.URI_NS_SOAP_ENVELOPE);
 	    
-	    // Forces a preload of the current MOBY Object ontology
-	    MobyDataType.getDataType("Object");
-
-	    // Not sure we actually need MobyRequest yet...
+	    // Determine the Moby Central (and hence ontologies) to associate with the service
+	    String centralURL = null;
+	    mobyService ann = 
+		this.getClass().getAnnotation(mobyService.class);
+	    if(ann != null){
+		centralURL = ann.centralEndpoint();
+	    }
  	    if(getCoCInitParameter(MOBY_CENTRAL_URL_PARAM) != null){
- 		mobyRequest = new MobyRequest(new CentralCachedCallsImpl(getCoCInitParameter(MOBY_CENTRAL_URL_PARAM)));
+		centralURL = getCoCInitParameter(MOBY_CENTRAL_URL_PARAM);
+	    }
+
+	    if(centralURL != null && centralURL.length() > 0){
+ 		mobyRequest = new MobyRequest(new CentralCachedCallsImpl(centralURL));
  	    }
  	    else{
  		mobyRequest = new MobyRequest(new CentralCachedCallsImpl());
  	    }
+	    registry = new Registry("any_synonym", 
+				    mobyRequest.getCentralImpl().getRegistryEndpoint(),
+				    mobyRequest.getCentralImpl().getRegistryNamespace());
+	    // Forces a preload of the current MOBY Object ontology
+	    MobyDataType.getDataType("Object", registry);
+
 	    mobyRequest.setDebugMode(isDebug);
 	    
 	}catch(Exception e){
@@ -640,6 +656,15 @@
 	isInitialized = true;
     }
 
+    /**
+     * Returns the Moby Central server that the service is associated with,
+     * based on the web.xml and the servlet annotation.  If the servlet hasn't
+     * been initialized yet (init() hasn't been called), null will be returned.
+     */
+    public Central getCentralImpl(){
+	return mobyRequest == null ? null : mobyRequest.getCentralImpl();
+    }
+
     protected String getCoCInitParameter(String paramName){
 	javax.servlet.ServletConfig config = getServletConfig();
 	if(config != null){
@@ -740,7 +765,7 @@
 	    throw new Exception("Required " + MOBY_SERVICETYPE_PARAM + 
 				" parameter in servlet config cannot be blank");
 	}
-	MobyServiceType serviceType = MobyServiceType.getServiceType(param);
+	MobyServiceType serviceType = MobyServiceType.getServiceType(param, registry);
 	if(serviceType == null){
 	    throw new Exception("The service type specified (" + param + 
 				") was not found in the service type ontology");
@@ -1038,7 +1063,7 @@
 	    dataTemplate = new MobyPrimaryDataSimple(name);
 	}
 
-	MobyDataType type = MobyDataType.getDataType(objectType);
+	MobyDataType type = MobyDataType.getDataType(objectType, registry);
 	if(type == null){
 	    throw new Exception("The parameter specification (" + 
 				spec + ") has a data type not found in the " +
@@ -1056,7 +1081,7 @@
 	// namespace is optional
 	if(st.hasMoreTokens()){
 	    String namespaceValue = st.nextToken();
-	    MobyNamespace nsObject = MobyNamespace.getNamespace(namespaceValue);
+	    MobyNamespace nsObject = MobyNamespace.getNamespace(namespaceValue, registry);
 	    if(nsObject == null){
 		System.err.println("WARNING: The parameter specification (" + 
 			       spec + ") has a namespace not found in the " +
@@ -1190,7 +1215,7 @@
 
         MobyContentInstance testData = null;
 	try{
-           testData = MobyDataUtils.fromXMLDocument(source.openStream());
+           testData = MobyDataUtils.fromXMLDocument(source.openStream(), registry);
         } catch(Exception e){
            System.err.println("The test data was invalid:");
            e.printStackTrace();

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/mobyService.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/service/mobyService.java	2007/02/08 16:59:58	1.2
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/mobyService.java	2007/12/17 18:31:09	1.3
@@ -22,5 +22,9 @@
     String[] out(); 
     String type();
     String[] description();
+    /**
+     * The URL of the Moby Central server with which the service will be registered.  If left blank or null, the default MOBY Central will be used.
+     */
+    String centralEndpoint() default "";
     boolean authoritative() default false;
 }




More information about the MOBY-guts mailing list