modified synchronization method for worklet arrival. I thought incorrectly

png3 [2001-04-18 19:49:50]
modified synchronization method for worklet arrival.  I thought incorrectly
that wait()-ing on an object released _all_ of its locks
Filename
MPUtil.java
ParserThread.java
SienaTest.java
diff --git a/MPUtil.java b/MPUtil.java
index 30d0a6a..9be604d 100644
--- a/MPUtil.java
+++ b/MPUtil.java
@@ -1,115 +1,119 @@
-package psl.metaparser;
-
-import java.text.DateFormat;
-import java.util.*;
-import java.io.*;
-import java.net.URL;
-
-// import oracle.xml.parser.schema.*;
-// import oracle.xml.parser.v2.*;
-import org.xml.sax.*;
-import org.xml.sax.helpers.*;
-
-/** Various static utility methods for metaparser.
-  *
+package psl.metaparser;
+
+import java.text.DateFormat;
+import java.util.*;
+import java.io.*;
+import java.net.URL;
+
+// import oracle.xml.parser.schema.*;
+// import oracle.xml.parser.v2.*;
+import org.xml.sax.*;
+import org.xml.sax.helpers.*;
+
+/** Various static utility methods for metaparser.
+  *
   * $Log$
-  * Revision 2.4  2001-02-05 06:35:16  png3
+  * Revision 2.5  2001-04-18 19:49:50  png3
+  * modified synchronization method for worklet arrival.  I thought incorrectly
+  * that wait()-ing on an object released _all_ of its locks
+  *
+  * Revision 2.4  2001/02/05 06:35:16  png3
   * Post California version
-  *
-  * Revision 2.3  2001/01/30 10:16:55  png3
-  * Almost working...
-  *
-  * Revision 2.2  2001/01/29 04:04:48  png3
-  * Added package psl.metaparser statements.  Can you say "Oops?"
-  *
-  * Revision 2.1  2001/01/28 17:52:17  png3
-  * New version of Metaparser: fully multithreaded.  PrintWriter logs.
-  *
-  */
-class MPUtil {
-
-  /** Generate a timestamp string */
-  public static String timestamp() {
-    final DateFormat df =
-    	DateFormat.getTimeInstance(DateFormat.MEDIUM);
-    return df.format(new Date());
-  }
-
-  public static String makeQuery(String elm) {
-    String s = new String("<?xml version=\"1.0\"?>");
-    s += "<schemaQuery version=\"1.0\" name=\""+ elm+ "\">";
-    s += "<xpath>/" + elm + "</xpath>";
-    s += "</schemaQuery>";
-    return s;
-  }
-
-  public static String printLoc(Locator l) {
-    return ("(" + l.getLineNumber() + ":"
-    	+ l.getColumnNumber() + ")");
-  }
-
-  /** pulls module name out of oracle response XML */
-  // TODO: integrate with other logging...
-  public static String extractModuleName(String s) {
-    final String fn = "MPU_extractModuleName: ";
-    final String startTag = "<module";
-    final String endTok = "</module>";
-    int startIdx = s.indexOf(startTag);
-    startIdx = s.indexOf(">", startIdx);
-    int endIdx = s.indexOf(endTok, startIdx);
-    String result = s.substring(startIdx + 1, endIdx);
-    System.err.println(fn+"Expected Module Name:\n" + result);
-    return result;
-  }
-
-  /** pulls subschema out of oracle response XML */
-  // TODO: integrate with other logging...
-  public static void extractSchema(String s) {
-    final String fn = "MPU_extractSchema: ";
-    final String startTag = "<subschema>";
-    final String endTag = "</subschema>";
-    int startIdx = s.indexOf(startTag)+startTag.length();
-    int endIdx = s.indexOf(endTag, startIdx);
-    String result = s.substring(startIdx, endIdx);
-    System.err.println(fn+"extracted schema String:\n" + result);
-
-    // StringReader sr = new StringReader(result);
-    // XMLSchema schema = null;
-    try {
-      FileWriter schema = new FileWriter("schema.xsd");
-      schema.write(result);
-      schema.close();
-      // URL base = new URL("http://www.w3.org/1999/XMLSchema-instance");
-      // XSDBuilder b = new XSDBuilder();
-      // schema = (XMLSchema)b.build(sr, base);
-    } catch (Exception e) {
-      System.err.println(fn+"error while building schema");
-      System.err.println(e);
-      return;
-    }
-  }
-
-  // got this from Oracle, but I think it's been superseded
-  // by the built-in toURL() method of File
-  /*
-  static URL fileToURL(String fname) {
-
-    File file = new File(fname);
-
-    String path = file.getAbsolutePath();
-    String fSep = System.getProperty("file.separator");
-
-    if ((fSep != null) && (fSep.length() == 1)) {
-      path = path.replace(fSep.charAt(0), '/');
-    }
-    if ((path.length() > 0) && (path.charAt(0) != '/')) {
-      path = '/' + path;
-    }
-    try {
-      return new URL("file", null, path);
-    } catch (java.net.MalformedURLException e) {
-      throw new Error("unexpected MalformedURLException");
-    }
-  }
-  */
-}
+  *
+  * Revision 2.3  2001/01/30 10:16:55  png3
+  * Almost working...
+  *
+  * Revision 2.2  2001/01/29 04:04:48  png3
+  * Added package psl.metaparser statements.  Can you say "Oops?"
+  *
+  * Revision 2.1  2001/01/28 17:52:17  png3
+  * New version of Metaparser: fully multithreaded.  PrintWriter logs.
+  *
+  */
+class MPUtil {
+
+  /** Generate a timestamp string */
+  public static String timestamp() {
+    final DateFormat df =
+    	DateFormat.getTimeInstance(DateFormat.MEDIUM);
+    return df.format(new Date());
+  }
+
+  public static String makeQuery(String elm) {
+    String s = new String("<?xml version=\"1.0\"?>");
+    s += "<schemaQuery version=\"1.0\" name=\""+ elm+ "\">";
+    s += "<xpath>/" + elm + "</xpath>";
+    s += "</schemaQuery>";
+    return s;
+  }
+
+  public static String printLoc(Locator l) {
+    return ("(" + l.getLineNumber() + ":"
+    	+ l.getColumnNumber() + ")");
+  }
+
+  /** pulls module name out of oracle response XML */
+  // TODO: integrate with other logging...
+  public static String extractModuleName(String s) {
+    final String fn = "MPU_extractModuleName: ";
+    final String startTag = "<module";
+    final String endTok = "</module>";
+    int startIdx = s.indexOf(startTag);
+    startIdx = s.indexOf(">", startIdx);
+    int endIdx = s.indexOf(endTok, startIdx);
+    String result = s.substring(startIdx + 1, endIdx);
+    System.err.println(fn+"Expected Module Name:\n" + result);
+    return result;
+  }
+
+  /** pulls subschema out of oracle response XML */
+  // TODO: integrate with other logging...
+  public static void extractSchema(String s) {
+    final String fn = "MPU_extractSchema: ";
+    final String startTag = "<subschema>";
+    final String endTag = "</subschema>";
+    int startIdx = s.indexOf(startTag)+startTag.length();
+    int endIdx = s.indexOf(endTag, startIdx);
+    String result = s.substring(startIdx, endIdx);
+    System.err.println(fn+"extracted schema String:\n" + result);
+
+    // StringReader sr = new StringReader(result);
+    // XMLSchema schema = null;
+    try {
+      FileWriter schema = new FileWriter("schema.xsd");
+      schema.write(result);
+      schema.close();
+      // URL base = new URL("http://www.w3.org/1999/XMLSchema-instance");
+      // XSDBuilder b = new XSDBuilder();
+      // schema = (XMLSchema)b.build(sr, base);
+    } catch (Exception e) {
+      System.err.println(fn+"error while building schema");
+      System.err.println(e);
+      return;
+    }
+  }
+
+  // got this from Oracle, but I think it's been superseded
+  // by the built-in toURL() method of File
+  /*
+  static URL fileToURL(String fname) {
+
+    File file = new File(fname);
+
+    String path = file.getAbsolutePath();
+    String fSep = System.getProperty("file.separator");
+
+    if ((fSep != null) && (fSep.length() == 1)) {
+      path = path.replace(fSep.charAt(0), '/');
+    }
+    if ((path.length() > 0) && (path.charAt(0) != '/')) {
+      path = '/' + path;
+    }
+    try {
+      return new URL("file", null, path);
+    } catch (java.net.MalformedURLException e) {
+      throw new Error("unexpected MalformedURLException");
+    }
+  }
+  */
+}
diff --git a/ParserThread.java b/ParserThread.java
index 985febb..761fa0a 100644
--- a/ParserThread.java
+++ b/ParserThread.java
@@ -10,6 +10,7 @@ import org.apache.xerces.parsers.*;
 // import psl.worklets2.worklets.*;
 import psl.worklets.*;
 import psl.codetransfer.*;
+import psl.kx.*;

 import siena.*;

@@ -23,7 +24,11 @@ import psl.tagprocessor.TagProcessor;
   * Spawns Validators/SubParsers to validate subcomponents.
   *
   * $Log$
-  * Revision 2.8  2001-04-11 18:55:17  png3
+  * Revision 2.9  2001-04-18 19:49:50  png3
+  * modified synchronization method for worklet arrival.  I thought incorrectly
+  * that wait()-ing on an object released _all_ of its locks
+  *
+  * Revision 2.8  2001/04/11 18:55:17  png3
   * fixed bug with not storing object ref in _wklArrivals
   *
   * Revision 2.7  2001/03/14 08:17:13  png3
@@ -167,13 +172,16 @@ class ParserThread extends DefaultHandler
 	    prDbg(fn+"worklet had already arrived:"+
 	    	(Date)_wklArrivals.get(requestID));
 	  } else {
-	    Object lockObj = new Object();
-	    _wklArrivals.put(requestID, lockObj);
-	    synchronized (lockObj) {
-	      prDbg(fn+"waiting for worklet arrival:" + MPUtil.timestamp());
-	      lockObj.wait();
+	    // Object lockObj = new Object();
+	    //_wklArrivals.put(requestID, lockObj);
+	    _wklArrivals.put(requestID, null);
+	    prDbg(fn+"waiting for worklet arrival:" + MPUtil.timestamp());
+	    _wklArrivals.wait();
+	    Date d = (Date) _wklArrivals.get(requestID);
+	    if (d == null) {
+	      _wklArrivals.wait();
 	    }
-	    prDbg(fn+"worklet arrived:" + MPUtil.timestamp());
+	    prDbg(fn+"worklet arrived:" + d);
 	  }
 	}

@@ -215,6 +223,11 @@ class ParserThread extends DefaultHandler
 	}

 	prDbg(fn+"Resulting Hashtable is: " + ht);
+	// TODO what's my number?
+	KXNotification edAlert = KXNotification.EDInputKXNotification(
+					"psl.metaparser.ParserThread", 0, ht);
+	slt.publish(edAlert);
+
      }

     } catch (Exception e) {
diff --git a/SienaTest.java b/SienaTest.java
index 3848de2..90a412d 100644
--- a/SienaTest.java
+++ b/SienaTest.java
@@ -1,89 +1,93 @@
-package psl.metaparser;
-
-import java.io.*;
-import java.net.*;
-import java.util.*;
-
-import psl.kx.*;
-
-import siena.*;
-
-/** Generates ED-like XML notification.
-  * One argument: xml message to include.
-  *
+package psl.metaparser;
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+
+import psl.kx.*;
+
+import siena.*;
+
+/** Generates ED-like XML notification.
+  * One argument: xml message to include.
+  *
   * $Log$
-  * Revision 2.4  2001-02-05 06:35:16  png3
+  * Revision 2.5  2001-04-18 19:49:50  png3
+  * modified synchronization method for worklet arrival.  I thought incorrectly
+  * that wait()-ing on an object released _all_ of its locks
+  *
+  * Revision 2.4  2001/02/05 06:35:16  png3
   * Post California version
-  *
-  * Revision 2.3  2001/01/30 10:16:55  png3
-  * Almost working...
-  *
-  * Revision 2.2  2001/01/29 04:04:48  png3
-  * Added package psl.metaparser statements.  Can you say "Oops?"
-  *
-  * Revision 2.1  2001/01/28 17:52:17  png3
-  * New version of Metaparser: fully multithreaded.  PrintWriter logs.
-  *
-  */
-public class SienaTest {
-
-  /** Constructor */
-  public static void main(String[] args) {
-
-    String xml = null;
-    String s;
-    String master = "senp://canal.psl.cs.columbia.edu:4321";
-
-    if (args.length < 1) {
-    	System.err.println("Usage: SienaTest foo.xml [senp://blah]");
-    } else if (args.length == 2) {
-      master = args[1];
-    }
-
-
-    HierarchicalDispatcher hd = new HierarchicalDispatcher();
-    try {
-      hd.setReceiver(new TCPPacketReceiver(31339));
-      hd.setMaster(master);
-    } catch (IOException ioe) {
-      System.err.println("Unable to set hd receiver:" + ioe);
-      return;
-    } catch (InvalidSenderException ise) {
-      System.err.println("Invalid Sender:" + ise);
-      return;
-    }
-
-    System.err.println("Reading test file " + args[0]);
-    StringBuffer sb = new StringBuffer();
-    s = null;
-    try {
-      BufferedReader tf_br = new BufferedReader(new FileReader(args[0]));
-      do {
-	s = tf_br.readLine();
-	if (s != null) {
-	  sb.append(s);
-	  sb.append("\n");
-	}
-      } while (s != null);
-    } catch (IOException ioe) {
-      System.err.println("Exception when reading " + args[0] + ":" + ioe);
-      return;
-    }
-    xml = sb.toString();
-    System.err.println("About to parse:\n" + xml+"\n.");
-
-    Notification n = KXNotification.ProbeKXNotification("Biff-Probe", 666, xml);
-/*
-    n.putAttribute("Source", "EventDistiller");
-    n.putAttribute("Type", "DataToMetaParser");
-    n.putAttribute("SmartEvent", xml);
-*/
-    try {
-      hd.publish(n);
-    } catch (SienaException se) {
-      System.err.println("Siena exception on publish:" + se);
-      return;
-    }
-    hd.shutdown();
-  }
-}
+  *
+  * Revision 2.3  2001/01/30 10:16:55  png3
+  * Almost working...
+  *
+  * Revision 2.2  2001/01/29 04:04:48  png3
+  * Added package psl.metaparser statements.  Can you say "Oops?"
+  *
+  * Revision 2.1  2001/01/28 17:52:17  png3
+  * New version of Metaparser: fully multithreaded.  PrintWriter logs.
+  *
+  */
+public class SienaTest {
+
+  /** Constructor */
+  public static void main(String[] args) {
+
+    String xml = null;
+    String s;
+    String master = "senp://canal.psl.cs.columbia.edu:4321";
+
+    if (args.length < 1) {
+    	System.err.println("Usage: SienaTest foo.xml [senp://blah]");
+    } else if (args.length == 2) {
+      master = args[1];
+    }
+
+
+    HierarchicalDispatcher hd = new HierarchicalDispatcher();
+    try {
+      hd.setReceiver(new TCPPacketReceiver(31339));
+      hd.setMaster(master);
+    } catch (IOException ioe) {
+      System.err.println("Unable to set hd receiver:" + ioe);
+      return;
+    } catch (InvalidSenderException ise) {
+      System.err.println("Invalid Sender:" + ise);
+      return;
+    }
+
+    System.err.println("Reading test file " + args[0]);
+    StringBuffer sb = new StringBuffer();
+    s = null;
+    try {
+      BufferedReader tf_br = new BufferedReader(new FileReader(args[0]));
+      do {
+	s = tf_br.readLine();
+	if (s != null) {
+	  sb.append(s);
+	  sb.append("\n");
+	}
+      } while (s != null);
+    } catch (IOException ioe) {
+      System.err.println("Exception when reading " + args[0] + ":" + ioe);
+      return;
+    }
+    xml = sb.toString();
+    System.err.println("About to parse:\n" + xml+"\n.");
+
+    Notification n = KXNotification.ProbeKXNotification("Biff-Probe", 666, xml);
+/*
+    n.putAttribute("Source", "EventDistiller");
+    n.putAttribute("Type", "DataToMetaParser");
+    n.putAttribute("SmartEvent", xml);
+*/
+    try {
+      hd.publish(n);
+    } catch (SienaException se) {
+      System.err.println("Siena exception on publish:" + se);
+      return;
+    }
+    hd.shutdown();
+  }
+}