[MOBY-guts] biomoby commit

Martin Senger senger at dev.open-bio.org
Sat Feb 23 13:58:32 UTC 2008


senger
Sat Feb 23 08:58:32 EST 2008
Update of /home/repository/moby/moby-live/Java/src/Clients
In directory dev.open-bio.org:/tmp/cvs-serv3084/src/Clients

Modified Files:
	CacheRegistryClient.java MirrorRegistry.java MobyGraphs.java 
	MosesGenerators.java 
Log Message:
Merging old registry caching (without RDF) and the new one. Big changes - more will follow.

moby-live/Java/src/Clients CacheRegistryClient.java,1.8,1.9 MirrorRegistry.java,1.2,1.3 MobyGraphs.java,1.12,1.13 MosesGenerators.java,1.3,1.4
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/Clients/CacheRegistryClient.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- /home/repository/moby/moby-live/Java/src/Clients/CacheRegistryClient.java	2005/11/20 12:30:51	1.8
+++ /home/repository/moby/moby-live/Java/src/Clients/CacheRegistryClient.java	2008/02/23 13:58:32	1.9
@@ -7,7 +7,10 @@
 //
 
 import org.biomoby.shared.*;
-import org.biomoby.client.*;
+import org.biomoby.shared.CentralCached;
+
+import org.biomoby.client.CmdLineHelper;
+import org.biomoby.client.CentralDigestCachedImpl;
 
 import org.biomoby.shared.event.LogListener;
 import org.biomoby.shared.event.Notifier;
@@ -32,24 +35,10 @@
  * @version $Id$
  */
 
-public class CacheRegistryClient {
-
-    /*************************************************************************
-     * Return a help text how to use this client.
-     *************************************************************************/
-    public static String getUsage() {
-	String helpFile = "help/CacheRegistryClient_usage.txt";
-	try {
-	    return new String (FileUtils.findAndGetBinaryFile (helpFile));
-	} catch (GException e) {
-	    return
-		"Sorry but an error occured.\n" +
-		"I cannot find the help file '" + helpFile + "'.\n" +
-		e.getMessage();
-	}
-    }
+public class CacheRegistryClient
+    extends CmdLineHelper {
 
-    static boolean verbose;
+    static boolean moreVerbose = false;
 
     /*************************************************************************
      *
@@ -59,55 +48,43 @@
     public static void main (String [] args) {
 	try {
 
-	    BaseCmdLine cmd = new BaseCmdLine (args, true);
-	    if (cmd.hasParam ("-help") || cmd.hasParam ("-h")) {
-		System.out.print (CacheRegistryClient.getUsage());
-		System.exit (0);
-	    }
+	    BaseCmdLine cmd = getCmdLine (args, CacheRegistryClient.class);
+
+	    // where is a Moby registry
+	    CentralCached worker = getCachableRegistryWorker (cmd);
 
 	    // there is not much to do without -cachedir
 	    String cacheDir = cmd.getParam ("-cachedir");
 	    if (cacheDir == null) {
-		System.err.println ("Parameter -cachedir must be specified.");
-		System.exit (1);
+		emsgln ("Parameter -cachedir must be specified.");
+		exit (1);
 	    }
-
-	    // where is a Moby registry
-	    CentralAll worker =
-		new CentralDigestCachedImpl (cmd.getParam ("-e"),
-					     cmd.getParam ("-uri"),
-					     cacheDir);
-	    CentralDigestCachedImpl castWorker = (CentralDigestCachedImpl)worker;
 	
 	    // how much to show
-	    verbose = cmd.hasOption ("-v");
+	    moreVerbose = cmd.hasOption ("-v");
 	    if (! cmd.hasOption ("-q"))
-		((Notifier)castWorker).addNotificationListener (new LogListener());
-
-	    if (cmd.hasOption ("-debug")) {
-		worker.setDebug (true);
-	    }
+		worker.addNotificationListener (new LogListener());
 
 	    //
 	    // [re-]fill the cache
 	    //
 	    if (cmd.hasOption ("-fill") || cmd.hasOption ("-fill-d")) {
-		castWorker.removeFromCache (CentralDigestCachedImpl.CACHE_PART_DATATYPES);
+		worker.removeFromCache (CentralCached.CACHE_PART_DATATYPES);
 		decorationLn ("Retrieving data types...");
 		worker.getDataTypes();
 	    }
 	    if (cmd.hasOption ("-fill") || cmd.hasOption ("-fill-s")) {
-		castWorker.removeFromCache (CentralDigestCachedImpl.CACHE_PART_SERVICES);
+		worker.removeFromCache (CentralCached.CACHE_PART_SERVICES);
 		decorationLn ("Retrieving services...");
 		worker.getServices();
 	    }
 	    if (cmd.hasOption ("-fill") || cmd.hasOption ("-fill-t")) {
-		castWorker.removeFromCache (CentralDigestCachedImpl.CACHE_PART_SERVICETYPES);
+		worker.removeFromCache (CentralCached.CACHE_PART_SERVICETYPES);
 		decorationLn ("Retrieving service types...");
 		worker.getFullServiceTypes();
 	    }
 	    if (cmd.hasOption ("-fill") || cmd.hasOption ("-fill-n")) {
-		castWorker.removeFromCache (CentralDigestCachedImpl.CACHE_PART_NAMESPACES);
+		worker.removeFromCache (CentralCached.CACHE_PART_NAMESPACES);
 		decorationLn ("Retrieving namespaces...");
 		worker.getFullNamespaces();
 	    }
@@ -117,38 +94,38 @@
 	    //
 	    if (cmd.hasOption ("-update") || cmd.hasOption ("-update-d")) {
 		decorationLn ("Updating data types...");
-		castWorker.updateCache (CentralDigestCachedImpl.CACHE_PART_DATATYPES);
+		worker.updateCache (CentralCached.CACHE_PART_DATATYPES);
 	    }
 	    if (cmd.hasOption ("-update") || cmd.hasOption ("-update-s")) {
 		decorationLn ("Updating services...");
-		castWorker.updateCache (CentralDigestCachedImpl.CACHE_PART_SERVICES);
+		worker.updateCache (CentralCached.CACHE_PART_SERVICES);
 	    }
 	    if (cmd.hasOption ("-update") || cmd.hasOption ("-update-t")) {
 		decorationLn ("Updating service types...");
-		castWorker.updateCache (CentralDigestCachedImpl.CACHE_PART_SERVICETYPES);
+		worker.updateCache (CentralCached.CACHE_PART_SERVICETYPES);
 	    }
 	    if (cmd.hasOption ("-update") || cmd.hasOption ("-update-n")) {
 		decorationLn ("Updating namespaces...");
-		castWorker.updateCache (CentralDigestCachedImpl.CACHE_PART_NAMESPACES);
+		worker.updateCache (CentralCached.CACHE_PART_NAMESPACES);
 	    }
 
 	    //
 	    // remove the cache
 	    //
 	    if (cmd.hasOption ("-remove") || cmd.hasOption ("-remove-d")) {
-		castWorker.removeFromCache (CentralDigestCachedImpl.CACHE_PART_DATATYPES);
+		worker.removeFromCache (CentralCached.CACHE_PART_DATATYPES);
 		decorationLn ("Cache for data types removed.");
 	    }
 	    if (cmd.hasOption ("-remove") || cmd.hasOption ("-remove-s")) {
-		castWorker.removeFromCache (CentralDigestCachedImpl.CACHE_PART_SERVICES);
+		worker.removeFromCache (CentralCached.CACHE_PART_SERVICES);
 		decorationLn ("Cache for services removed.");
 	    }
 	    if (cmd.hasOption ("-remove") || cmd.hasOption ("-remove-t")) {
-		castWorker.removeFromCache (CentralDigestCachedImpl.CACHE_PART_SERVICETYPES);
+		worker.removeFromCache (CentralCached.CACHE_PART_SERVICETYPES);
 		decorationLn ("Cache for service types removed.");
 	    }
 	    if (cmd.hasOption ("-remove") || cmd.hasOption ("-remove-n")) {
-		castWorker.removeFromCache (CentralDigestCachedImpl.CACHE_PART_NAMESPACES);
+		worker.removeFromCache (CentralCached.CACHE_PART_NAMESPACES);
 		decorationLn ("Cache for namespaces removed.");
 	    }
 
@@ -157,40 +134,37 @@
 	    //
 	    if (cmd.hasOption ("-info") || cmd.hasOption ("-info-d")) {
 		decorationLn ("Cache for data types...");
-		System.out.println
-		    (castWorker.getCacheInfoFormatted (CentralDigestCachedImpl.CACHE_PART_DATATYPES));
+		msgln
+		    (worker.getCacheInfoFormatted (CentralCached.CACHE_PART_DATATYPES));
 	    }
 	    if (cmd.hasOption ("-info") || cmd.hasOption ("-info-s")) {
 		decorationLn ("Cache for service authorities...");
-		System.out.println
-		    (castWorker.getCacheInfoFormatted (CentralDigestCachedImpl.CACHE_PART_SERVICES));
+		msgln
+		    (worker.getCacheInfoFormatted (CentralCached.CACHE_PART_SERVICES));
 	    }
 	    if (cmd.hasOption ("-info") || cmd.hasOption ("-info-t")) {
 		decorationLn ("Cache for service types...");
-		System.out.println
-		    (castWorker.getCacheInfoFormatted (CentralDigestCachedImpl.CACHE_PART_SERVICETYPES));
+		msgln
+		    (worker.getCacheInfoFormatted (CentralCached.CACHE_PART_SERVICETYPES));
 	    }
 	    if (cmd.hasOption ("-info") || cmd.hasOption ("-info-n")) {
 		decorationLn ("Cache for namespaces...");
-		System.out.println
-		    (castWorker.getCacheInfoFormatted (CentralDigestCachedImpl.CACHE_PART_NAMESPACES));
+		msgln
+		    (worker.getCacheInfoFormatted (CentralCached.CACHE_PART_NAMESPACES));
 	    }
 
-	} catch (Exception e) {
-	    System.err.println ("===ERROR===");
-	    e.printStackTrace();
-	    System.err.println ("===========");
+	} catch (Throwable e) {
+	    processErrorAndExit (e);
 	}
     }
 
     /*************************************************************************
-     * Print 'msg' but only if in verbose mode
+     * Print 'msg' but only if in "more verbose" mode.
      *************************************************************************/
     static void decoration (String msg) {
- 	if (verbose) System.out.print (msg);
+ 	if (moreVerbose) msg (msg);
     }
     static void decorationLn (String msg) {
- 	if (verbose) System.out.println (msg);
+ 	if (moreVerbose) msgln (msg);
     }
-
 }

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/Clients/MirrorRegistry.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Java/src/Clients/MirrorRegistry.java	2005/12/20 20:00:41	1.2
+++ /home/repository/moby/moby-live/Java/src/Clients/MirrorRegistry.java	2008/02/23 13:58:32	1.3
@@ -7,7 +7,9 @@
 //
 
 import org.biomoby.shared.*;
-import org.biomoby.client.*;
+import org.biomoby.client.CmdLineHelper;
+import org.biomoby.client.CentralImpl;
+import org.biomoby.shared.Central;
 
 import org.tulsoft.tools.BaseCmdLine;
 import org.tulsoft.shared.FileUtils;
@@ -23,24 +25,8 @@
  * @version $Id$
  */
 
-public class MirrorRegistry {
-
-    /*************************************************************************
-     * Return a help text how to use this client.
-     *************************************************************************/
-    public static String getUsage() {
-	String helpFile = "help/MirrorRegistry_usage.txt";
-	try {
-	    return new String (FileUtils.findAndGetBinaryFile (helpFile));
-	} catch (GException e) {
-	    return
-		"Sorry but an error occured.\n" +
-		"I cannot find the help file '" + helpFile + "'.\n" +
-		e.getMessage();
-	}
-    }
-
-    static boolean verbose;
+public class MirrorRegistry
+    extends CmdLineHelper {
 
     /*************************************************************************
      *
@@ -50,11 +36,7 @@
     public static void main (String [] args) {
 	try {
 
-	    BaseCmdLine cmd = new BaseCmdLine (args, true);
-	    if (cmd.hasParam ("-help") || cmd.hasParam ("-h")) {
-		System.out.print (CacheRegistryClient.getUsage());
-		System.exit (0);
-	    }
+	    BaseCmdLine cmd = getCmdLine (args, MirrorRegistry.class);
 
 	    // where are Moby registries
 	    String eTo = cmd.getParam ("-eTo");

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/Clients/MobyGraphs.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- /home/repository/moby/moby-live/Java/src/Clients/MobyGraphs.java	2008/02/22 09:37:38	1.12
+++ /home/repository/moby/moby-live/Java/src/Clients/MobyGraphs.java	2008/02/23 13:58:32	1.13
@@ -6,7 +6,7 @@
 //
 
 import org.biomoby.shared.*;
-import org.biomoby.shared.CentralAll;
+import org.biomoby.shared.CentralCached;
 
 import org.biomoby.client.CmdLineHelper;
 import org.biomoby.client.CentralDigestCachedImpl;
@@ -49,7 +49,7 @@
 	    String param;
 
 	    // where is a Moby registry
-	    CentralAll worker = getCachableRegistryWorker (cmd);
+	    CentralCached worker = getCachableRegistryWorker (cmd);
 
 	    // collect properties customizing graphs
 	    Properties props = new Properties();

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/Clients/MosesGenerators.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Java/src/Clients/MosesGenerators.java	2008/02/22 09:37:38	1.3
+++ /home/repository/moby/moby-live/Java/src/Clients/MosesGenerators.java	2008/02/23 13:58:32	1.4
@@ -11,6 +11,7 @@
 import org.biomoby.service.generator.ServicesGenerator;
 import org.biomoby.service.generator.Generator;
 import org.biomoby.shared.Central;
+import org.biomoby.shared.CentralCached;
 
 import org.tulsoft.tools.BaseCmdLine;
 import java.util.Properties;
@@ -49,10 +50,7 @@
 	try {
 
 	    BaseCmdLine cmd = getCmdLine (args, MosesGenerators.class);
-
-	    Central worker = getRegistryWorker (cmd);
-	    String registryEndpoint = worker.getRegistryEndpoint();
-	    String registryNamespace = worker.getRegistryNamespace();
+	    CentralCached worker = getCachableRegistryWorker (cmd);
 
 	    boolean generateDataTypes = cmd.hasOption ("-dt");
 	    boolean generateServices = cmd.hasOption ("-s");
@@ -77,8 +75,7 @@
 		else
 		    qmsgln ("Generating data types" +
 			    (outdir == null ? "..." : " into '" + outdir + "'... "));
-		DataTypesGenerator dtg
-		    = new DataTypesGenerator (registryEndpoint, registryNamespace, cacheDir);
+		DataTypesGenerator dtg = new DataTypesGenerator (worker);
 		Properties props = new Properties();
 		if (filter != null) props.put (Generator.GPROP_FILTER, filter);
 		if (outdir != null) props.put (Generator.GPROP_OUTDIR, outdir);
@@ -101,8 +98,7 @@
 		else
 		    qmsgln ("Generating services" +
 			    (outdir == null ? "..." : " into '" + outdir + "'... "));
-		ServicesGenerator sg
-		    = new ServicesGenerator (registryEndpoint, registryNamespace, cacheDir);
+		ServicesGenerator sg = new ServicesGenerator (worker);
 		Properties props = new Properties();
 		if (service != null) props.put (Generator.GPROP_SERVICE, service);
 		if (authority != null) props.put (Generator.GPROP_AUTH, authority);




More information about the MOBY-guts mailing list