[MOBY-guts] biomoby commit

Martin Senger senger at dev.open-bio.org
Thu May 31 13:42:51 UTC 2007


senger
Thu May 31 09:42:51 EDT 2007
Update of /home/repository/moby/moby-live/Java/src/Clients
In directory dev.open-bio.org:/tmp/cvs-serv1857/src/Clients

Modified Files:
	MobyCmdLineClient.java 
Log Message:
starting addign support for async services
moby-live/Java/src/Clients MobyCmdLineClient.java,1.14,1.15
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/Clients/MobyCmdLineClient.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- /home/repository/moby/moby-live/Java/src/Clients/MobyCmdLineClient.java	2007/05/29 03:51:46	1.14
+++ /home/repository/moby/moby-live/Java/src/Clients/MobyCmdLineClient.java	2007/05/31 13:42:51	1.15
@@ -13,6 +13,10 @@
 import org.tulsoft.shared.StringUtils;
 import org.tulsoft.shared.GException;
 
+import org.biomoby.registry.meta.RegistriesList;
+import org.biomoby.registry.meta.Registries;
+import org.biomoby.registry.meta.Registry;
+
 import java.util.*;
 import java.io.*;
 
@@ -80,11 +84,23 @@
 	    }
 
 	    verbose = !cmd.hasOption ("-q");
+	    String param;
 
 	    // where is a Moby registry
-	    Central worker = new CentralImpl (cmd.getParam ("-e"),
-					      cmd.getParam ("-uri"));
-	    String param;
+	    Central worker = null;
+	    if ((param = cmd.getParam ("-registry")) == null) {
+		worker = new CentralImpl (cmd.getParam ("-e"),
+					  cmd.getParam ("-uri"));
+	    } else {
+		final Registries regList = RegistriesList.getInstance();
+		Registry reg = regList.get (param);
+		if (reg == null) {
+		    System.err.println ("ERROR: Failed to find registry " + param);
+		    System.exit (1);
+		}
+		worker = new CentralImpl (reg.getEndpoint(),
+					  reg.getNamespace());
+	    }
 
 	    if (cmd.hasOption ("-debug")) {
 		worker.setDebug (true);
@@ -185,6 +201,16 @@
 		}
 	    }
 
+	    if (cmd.hasOption ("-lr")) {
+		boolean onlyNames = cmd.hasOption ("-on");
+		decorationLn ("Known BioMoby Registries:");
+		decorationLn ("-------------------------");
+		final Registries regList = RegistriesList.getInstance();
+		for (Registry reg: regList.getAll()) {
+		    System.out.println (onlyNames ? reg.getSynonym() : reg.toString());
+		}
+	    }
+
 	    //
 	    // retrieval of more complex entities
 	    //
@@ -625,43 +651,51 @@
 	    if ((params = cmd.getParam ("-scall", 2)) != null ) {
 		if (params[0] != null && params[1] != null) {
 
-		    // find URL of the wanted service
-		    decorationLn ("Looking for service '" + params[0] + "':");
+		    // find name and URL of the wanted service
 		    String serviceName = null;
+		    String authority = null;
 		    int pos = params[0].indexOf (",");
-		    MobyService[] services;
-		    MobyService pattern = null;
 		    if (pos == -1) {
 			serviceName = params[0];
-			pattern = new MobyService (serviceName);
-			pattern.setCategory ("");
-			services = worker.findService (pattern);
-
 		    } else if (pos == params[0].length() - 1) {
 			serviceName = params[0].substring (0, pos);
-			pattern = new MobyService (serviceName);
-			pattern.setCategory ("");
-			services = worker.findService (pattern);
 		    } else {
 			serviceName = params[0].substring (0, pos);
-			pattern = new MobyService (serviceName);
-			pattern.setAuthority (params[0].substring (pos+1));
+			authority = params[0].substring (pos+1);
+		    }
+		    String serviceURL = null;
+		    String category = MobyService.CATEGORY_MOBY;
+		    if ((serviceURL = cmd.getParam ("-url")) == null) {
+			// look in the registry
+			decorationLn ("Looking for service '" + params[0] + "':");
+			MobyService pattern = new MobyService (serviceName, authority);
 			pattern.setCategory ("");
-			services = worker.findService (pattern);
+			MobyService[] services = worker.findService (pattern);
+			if (services != null && services.length > 0) {
+			    serviceURL = services[0].getURL();
+			    category = services[0].getCategory();
+			}
 		    }
-		    if (services != null && services.length > 0) {
-			String serviceURL = services[0].getURL();
-			if (! serviceURL.equals ("")) {
-
-			    // call the service
-			    decorationLn ("Calling service '" + serviceName + "' with the input from '" + params[1] + "':");
-			    if (new File (params[1]).exists())
-				params[1] =  FileUtils.getFile (params[1]);
-			    decorationLn (params[1]);
-			    decorationLn ("---------------");
-			    Central serviceWorker = new CentralImpl (serviceURL, "http://biomoby.org/");
-			    System.out.println (serviceWorker.call (serviceName, params[1]));
+
+		    if (! "".equals (serviceURL)) {
+			String methodName = null;
+
+			if (MobyService.CATEGORY_MOBY_ASYNC.equals (category) ||
+			    cmd.hasOption ("-async")) {
+			    methodName = serviceName + MobyService.SUBMIT_ACTION_SUFFIX;
+			} else {
+			    methodName = serviceName;
 			}
+
+			// call the service
+			decorationLn ("Calling '" + methodName +
+				      "' with the input from '" + params[1] + "':");
+			if (new File (params[1]).exists())
+			    params[1] =  FileUtils.getFile (params[1]);
+			decorationLn (params[1]);
+			decorationLn ("---------------");
+			Central serviceWorker = new CentralImpl (serviceURL, "http://biomoby.org/");
+			System.out.println (serviceWorker.call (methodName, params[1]));
 		    }
 		}
 	    }




More information about the MOBY-guts mailing list