jkesselm 01/05/14 12:09:34
Modified: java/src/org/apache/xml/dtm Tag: DTM_EXP
CoroutineParser.java CoroutineSAXParser.java
CoroutineSAXParser_Xerces.java DTMBuilder.java
java/src/org/apache/xml/dtm/sax2dtm Tag: DTM_EXP
SAX2DTM.java
Log:
Links from SAX2DTM to CoroutineParser, for incremental build
Revision Changes Path
No revision
No revision
1.1.2.7 +10 -1
xml-xalan/java/src/org/apache/xml/dtm/Attic/CoroutineParser.java
Index: CoroutineParser.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/Attic/CoroutineParser.java,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -r1.1.2.6 -r1.1.2.7
--- CoroutineParser.java 2001/05/14 16:20:03 1.1.2.6
+++ CoroutineParser.java 2001/05/14 19:08:58 1.1.2.7
@@ -86,9 +86,18 @@
/** @return the coroutine ID number for this CoroutineParser object.
* Note that this isn't useful unless you know which CoroutineManager
- * you're talking to.
+ * you're talking to. Also note that the do...() methods encapsulate
+ * the common transactions with the CoroutineParser, so you shouldn't
+ * need this in most cases.
* */
public int getParserCoroutineID();
+
+ /** @return the CoroutineManager for this CoroutineParser object.
+ * If you're using the do...() methods, applications should only
+ * need to talk to the CoroutineManager once, to obtain the
+ * application's Coroutine ID.
+ * */
+ public CoroutineManager getCoroutineManager();
/** Register a SAX-style content handler for us to output to */
public void setContentHandler(ContentHandler handler);
1.1.2.7 +10 -0
xml-xalan/java/src/org/apache/xml/dtm/Attic/CoroutineSAXParser.java
Index: CoroutineSAXParser.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/Attic/CoroutineSAXParser.java,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -r1.1.2.6 -r1.1.2.7
--- CoroutineSAXParser.java 2001/05/14 16:20:05 1.1.2.6
+++ CoroutineSAXParser.java 2001/05/14 19:09:04 1.1.2.7
@@ -370,6 +370,16 @@
return fParserCoroutineID;
}
+ /** @return the CoroutineManager this CoroutineParser object is bound to.
+ * If you're using the do...() methods, applications should only
+ * need to talk to the CoroutineManager once, to obtain the
+ * application's Coroutine ID.
+ * */
+ public CoroutineManager getCoroutineManager()
+ {
+ return fCoroutineManager;
+ }
+
/** <p>In the SAX delegation code, I've inlined the count-down in
* the hope of encouraging compilers to deliver better
* performance. However, if we subclass (eg to directly connect the
1.1.2.5 +10 -0
xml-xalan/java/src/org/apache/xml/dtm/Attic/CoroutineSAXParser_Xerces.java
Index: CoroutineSAXParser_Xerces.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/Attic/CoroutineSAXParser_Xerces.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- CoroutineSAXParser_Xerces.java 2001/05/14 16:20:06 1.1.2.4
+++ CoroutineSAXParser_Xerces.java 2001/05/14 19:09:06 1.1.2.5
@@ -121,6 +121,16 @@
return fParserCoroutineID;
}
+ /** @return the CoroutineManager this CoroutineParser object is bound to.
+ * If you're using the do...() methods, applications should only
+ * need to talk to the CoroutineManager once, to obtain the
+ * application's Coroutine ID.
+ * */
+ public CoroutineManager getCoroutineManager()
+ {
+ return fCoroutineManager;
+ }
+
// Note name, needed to dodge the inherited Xerces setLexicalHandler
// which isn't public.
public void setLexHandler(org.xml.sax.ext.LexicalHandler handler)
1.1.2.6 +4 -4
xml-xalan/java/src/org/apache/xml/dtm/Attic/DTMBuilder.java
Index: DTMBuilder.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/Attic/DTMBuilder.java,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -r1.1.2.5 -r1.1.2.6
--- DTMBuilder.java 2001/05/10 20:09:24 1.1.2.5
+++ DTMBuilder.java 2001/05/14 19:09:08 1.1.2.6
@@ -95,9 +95,9 @@
* by breaking the attributes out of the SAX createEvent call and generating
* create-attribute (and create-namespace-declaration) calls.</p>
*
- * <p>Status: In progress. The hardest part is deciding exactly how
- * the initialization transactions work -- who tells who about which of
- * of their partners.</p>
+ * <p>Status: MOSTLY DEAD CODE -- Merged into DTM implementations; this
+ * class is being retained just for reference and can probably be discarded
+ * some time soon -- Check with Joe.</p>
* */
public class DTMBuilder
implements ContentHandler, LexicalHandler
@@ -183,7 +183,7 @@
// %TBD% parser should be passed in so we can plug in the
// Xalan version of other specific instances.
co_parser=new CoroutineSAXParser(fCoroutineManager,fAppCoroutine,parser);
- fParserCoroutine=co_parser.getParserCoroutine();
+ fParserCoroutine=co_parser.getParserCoroutineID();
co_parser.setContentHandler(this);
co_parser.setLexHandler(this); // Needed for comments, I think.
No revision
No revision
1.1.2.4 +89 -4
xml-xalan/java/src/org/apache/xml/dtm/sax2dtm/Attic/SAX2DTM.java
Index: SAX2DTM.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/sax2dtm/Attic/SAX2DTM.java,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- SAX2DTM.java 2001/05/14 16:17:59 1.1.2.3
+++ SAX2DTM.java 2001/05/14 19:09:28 1.1.2.4
@@ -84,6 +84,32 @@
/** simple DEBUG flag, for dumping diagnostics info. */
private static final boolean DEBUG = false;
+ /** If we're building the model incrementally on demand, we need to
+ * be able to tell the source when to send us more data.
+ *
+ * Note that if this has not been set, and you attempt to read ahead
+ * of the current build point, we'll probably throw a null-pointer
+ * exception. We could try to wait-and-retry instead, as a very poor
+ * fallback, but that has all the known problems with multithreading
+ * on multiprocessors and we Don't Want to Go There.
+ *
+ * @see setCoroutineParser
+ */
+ private CoroutineParser m_coroutineParser=null;
+
+ /** If we're building the model incrementally on demand, we need to
+ * be able to tell the source who to return the data to.
+ *
+ * Note that if this has not been set, and you attempt to read ahead
+ * of the current build point, we'll probably throw a MethodNotFound
+ * exception. We could try to wait-and-retry instead, as a very poor
+ * fallback, but that has all the known problems with multithreading
+ * on multiprocessors and we Don't Want to Go There.
+ *
+ * @see setCoroutineParser
+ */
+ private int m_appCoroutineID=-1;
+
/**
* The number of nodes, which is also used to determine the next
* node index.
@@ -206,6 +232,43 @@
m_previous = DTM.NULL;
}
+ /** Bind a CoroutineParser to this DTM. If we discover we need nodes
+ * that have not yet been built, we will ask this object to send us more
+ * events, and it will manage interactions with its data sources.
+ *
+ * Note that we do not actually build the CoroutineParser, since we don't
+ * know what source it's reading from, what thread that source will run in,
+ * or when it will run.
+ *
+ * @param coroutineParser The parser that we want to recieve events from
+ * on demand.
+ */
+ public void setCoroutineParser(CoroutineParser coroutineParser)
+ {
+ // Establish coroutine link so we can request more data
+ //
+ // Note: It's possible that some versions of CoroutineParser may
+ // not actually use a CoroutineManager, and hence may not require
+ // that we obtain an Application Coroutine ID. (This relies on the
+ // coroutine transaction details having been encapsulated in the
+ // CoroutineParser.do...() methods.)
+ m_coroutineParser=coroutineParser;
+ CoroutineManager cm=coroutineParser.getCoroutineManager();
+ if(cm!=null)
+ m_appCoroutineID=cm.co_joinCoroutineSet(-1);
+
+ // Establish SAX-stream link so we can receive the requested data
+ coroutineParser.setContentHandler(this);
+ coroutineParser.setLexHandler(this);
+
+ // Are the following really needed? coroutineParser doesn't yet
+ // support them, and they're mostly no-ops here...
+ //coroutineParser.setErrorHandler(this);
+ //coroutineParser.setDTDHandler(this);
+ //coroutineParser.setDeclHandler(this);
+ }
+
+
/**
* Directly call the
* characters method on the passed ContentHandler for the
@@ -417,10 +480,32 @@
if (identity >= m_size)
{
-
- // %TODO% CoRoutine stuff.
- // if (!nextNode())
- identity = DTM.NULL;
+ if(m_coroutineParser==null)
+ identity = DTM.NULL;
+ else while(identity >= m_size)
+ {
+ Object gotMore=m_coroutineParser.doMore(true,m_appCoroutineID);
+
+ // gotMore may be a Boolean (TRUE if still parsing, FALSE if
+ // EOF) or an exception if CoroutineParser malfunctioned
+ // (code error rather than user error).
+ //
+ // %REVIEW% Currently the ErrorHandlers sketched herein are
+ // no-ops, so I'm going to initially leave this also as a
+ // no-op.
+ if(!(gotMore instanceof Boolean))
+ {
+ // %TBD%
+ }
+
+ if(gotMore!=Boolean.TRUE & (identity >= m_size))
+ {
+ // EOF reached without satisfying the request
+ m_coroutineParser=null; // Drop connection, stop trying
+ // %TBD% deregister as its listener?
+ identity = DTM.NULL; // Record not-found.
+ }
+ }
}
return identity;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]