costin      01/06/21 16:46:45

  Modified:    java     build.xml
               java/src/org/apache/xml/dtm/ref CoroutineParser.java
                        CoroutineSAXFilterTest.java CoroutineSAXParser.java
                        CoroutineSAXParser_Xerces.java
                        DTMManagerDefault.java
  Log:
  Remove deps on xerces1.
  
  Revision  Changes    Path
  1.112     +11 -3     xml-xalan/java/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/build.xml,v
  retrieving revision 1.111
  retrieving revision 1.112
  diff -u -r1.111 -r1.112
  --- build.xml 2001/06/18 19:41:59     1.111
  +++ build.xml 2001/06/21 23:46:42     1.112
  @@ -50,7 +50,7 @@
     
     - Much of this file stolen from Stefano's xml-xerces build.xml  
     
  -   $Id: build.xml,v 1.111 2001/06/18 19:41:59 dmarston Exp $
  +   $Id: build.xml,v 1.112 2001/06/21 23:46:42 costin Exp $
      
   ==================================================================== -->
   
  @@ -167,6 +167,8 @@
            the tests-available property set for them.
       -->
       <available file="${tests.dir}" property="tests-available" />
  +    <available property="xerces.present" 
  +      classname="org.apache.xerces.parsers.SAXParser"/>
     </target>
   
     <!-- Must depend on jar since we use Xalan to process xml files -->
  @@ -224,8 +226,14 @@
       <!-- Compile XPath engine and some common utilities -->
       <javac srcdir="${src.dir}" 
              destdir="${build.classes}"
  -           includes="org/apache/xml/**/*.java,${xpath.reldir}/**/*.java"
  -           debug="${debug}"/>
  +           debug="${debug}" >
  +      <include name="org/apache/xml/**/*.java" />
  +      <include name="${xpath.reldir}/**/*.java" />
  +      <exclude name="**/CoroutineSAXFilterTest.java" 
  +     unless="xerces.present"  />
  +      <exclude name="**/CoroutineSAXParser_Xerces.java" 
  +     unless="xerces.present"  />
  +    </javac>
       <!-- Compile Xalan main engine (but not xsltc package yet) -->
       <javac srcdir="${src.dir}" 
              destdir="${build.classes}"
  
  
  
  1.3       +9 -0      xml-xalan/java/src/org/apache/xml/dtm/ref/CoroutineParser.java
  
  Index: CoroutineParser.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/CoroutineParser.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CoroutineParser.java      2001/06/12 19:15:43     1.2
  +++ CoroutineParser.java      2001/06/21 23:46:43     1.3
  @@ -62,6 +62,7 @@
   import java.io.IOException;
   import org.xml.sax.ext.LexicalHandler;
   import org.xml.sax.ContentHandler;
  +import org.xml.sax.XMLReader;
   
   /** <p>CoroutineParser is an API for parser threads that operate as
    * coroutines. See CoroutineSAXParser and CoroutineSAXParser_Xerces
  @@ -165,5 +166,13 @@
      * request.
      * */
     public void doTerminate(int appCoroutine);
  +
  +
  +    /**
  +     *  Initialize the coroutine parser. Same parameters could be passed
  +     *  in a non-default constructor, or by using using Class.forName and
  +     *  newInstance and then calling init()
  +     */
  +  public void init( CoroutineManager co, int appCoroutineID, XMLReader parser );
   
   } // class CoroutineParser
  
  
  
  1.3       +10 -2     
xml-xalan/java/src/org/apache/xml/dtm/ref/CoroutineSAXFilterTest.java
  
  Index: CoroutineSAXFilterTest.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/CoroutineSAXFilterTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CoroutineSAXFilterTest.java       2001/06/12 19:15:44     1.2
  +++ CoroutineSAXFilterTest.java       2001/06/21 23:46:43     1.3
  @@ -8,6 +8,7 @@
   import org.xml.sax.Attributes;
   import org.xml.sax.XMLReader;
   import java.io.IOException;
  +import javax.xml.parsers.*;
   
   /** Primitive unit test for CoroutineSAXParser in filtering mode:
    * Attempt coroutine parsing of documents indicated by arguments (as
  @@ -37,8 +38,15 @@
     {
       System.out.println("Starting in Filtering mode...");
   
  -    org.xml.sax.XMLReader theSAXParser=
  -      new org.apache.xerces.parsers.SAXParser();
  +    org.xml.sax.XMLReader theSAXParser=null;
  +    try {
  +     SAXParserFactory factory=SAXParserFactory.newInstance();
  +     SAXParser parser=factory.newSAXParser();
  +     theSAXParser=parser.getXMLReader();
  +    } catch( Exception ex ) {
  +     ex.printStackTrace();
  +     return;
  +    }
       
       CoroutineManager co = new CoroutineManager();
   
  
  
  
  1.3       +29 -19    
xml-xalan/java/src/org/apache/xml/dtm/ref/CoroutineSAXParser.java
  
  Index: CoroutineSAXParser.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/CoroutineSAXParser.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CoroutineSAXParser.java   2001/06/12 19:15:44     1.2
  +++ CoroutineSAXParser.java   2001/06/21 23:46:43     1.3
  @@ -127,6 +127,9 @@
     // Constructors
     //
   
  +  public CoroutineSAXParser() {
  +  }
  +  
     /** Create a CoroutineSAXParser which is not yet bound to a specific
      * SAX event source.
      *
  @@ -141,17 +144,7 @@
      * */
     public CoroutineSAXParser(CoroutineManager co, int appCoroutineID)
     {
  -    fXMLReader=null;    // No reader yet
  -
  -    eventcounter=frequency;
  -
  -    fCoroutineManager = co;
  -    fAppCoroutineID = appCoroutineID;
  -    fParserCoroutineID = co.co_joinCoroutineSet(-1);
  -    if (fParserCoroutineID == -1)
  -      throw new RuntimeException("co_joinCoroutineSet() failed");
  -
  -    fRunningInThread=false; // Unless overridden by the other constructor
  +    this.init( co, appCoroutineID, null );
     }
   
     /** Wrap a SAX2 XMLReader (parser or other event source)
  @@ -163,20 +156,37 @@
      */
     public CoroutineSAXParser(CoroutineManager co, int appCoroutineID,
                               XMLReader parser) {
  -    this(co,appCoroutineID);
  -    setXMLReader(parser);
  -
  -    fRunningInThread=true;
  -             org.apache.xalan.transformer.TransformerImpl.runTransformThread(this);
  -    //Thread t = new Thread(this);
  -    //t.setDaemon(false);
  -    //t.start();
  +    this.init( co, appCoroutineID, parser );
     }
   
     //
     // Public methods
     //
   
  +  public void init( CoroutineManager co, int appCoroutineID, XMLReader parser ) {
  +    fXMLReader=null;    // No reader yet
  +
  +    eventcounter=frequency;
  +
  +    fCoroutineManager = co;
  +    fAppCoroutineID = appCoroutineID;
  +    fParserCoroutineID = co.co_joinCoroutineSet(-1);
  +    if (fParserCoroutineID == -1)
  +      throw new RuntimeException("co_joinCoroutineSet() failed");
  +
  +    fRunningInThread=false; // Unless overridden by the other constructor
  +
  +    if( parser!=null ) {
  +      setXMLReader(parser);
  +      
  +      fRunningInThread=true;
  +      org.apache.xalan.transformer.TransformerImpl.runTransformThread(this);
  +      //Thread t = new Thread(this);
  +      //t.setDaemon(false);
  +      //t.start();
  +    }
  +  }
  +    
     /** Bind to the XMLReader. This operation is ignored if the reader has
      * previously been set.
      *
  
  
  
  1.3       +9 -3      
xml-xalan/java/src/org/apache/xml/dtm/ref/CoroutineSAXParser_Xerces.java
  
  Index: CoroutineSAXParser_Xerces.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/CoroutineSAXParser_Xerces.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CoroutineSAXParser_Xerces.java    2001/06/12 19:15:44     1.2
  +++ CoroutineSAXParser_Xerces.java    2001/06/21 23:46:44     1.3
  @@ -97,13 +97,19 @@
       //
       // Constructors
       //
  -
  +    public CoroutineSAXParser_Xerces() {
  +    }
  +    
       public CoroutineSAXParser_Xerces(CoroutineManager co, int appCoroutineID) {
  -      this(null,co,appCoroutineID);
  +      this.init( co,appCoroutineID, null);
       }
   
  +    // XXX the parameter order is confusing, different from CoroutineSAXParser
       public CoroutineSAXParser_Xerces(SAXParser ixsp, CoroutineManager co, int 
appCoroutineID) {
  +      this.init( co, appCoroutineID, ixsp); 
  +    }
   
  +    public void init( CoroutineManager co, int appCoroutineID, XMLReader ixsp ) {
         if(ixsp!=null)
           incrementalParser=ixsp;
         else
  @@ -111,7 +117,7 @@
         
         // incrementalParser.initHandlers(true, incrementalParser, incrementalParser);
       }
  -
  +    
       //
       // Factories
       //
  
  
  
  1.9       +13 -7     xml-xalan/java/src/org/apache/xml/dtm/ref/DTMManagerDefault.java
  
  Index: DTMManagerDefault.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMManagerDefault.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DTMManagerDefault.java    2001/06/20 14:02:30     1.8
  +++ DTMManagerDefault.java    2001/06/21 23:46:44     1.9
  @@ -245,7 +245,7 @@
   
           boolean haveXercesParser =
             (null != reader)
  -          && (reader instanceof org.apache.xerces.parsers.SAXParser);
  +          && 
(reader.getClass().getName().equals("org.apache.xerces.parsers.SAXParser") );
   
           if (haveXercesParser)
             incremental = true;  // No matter what.  %REVIEW%
  @@ -261,18 +261,24 @@
   
             // Create an CoRoutine ID for the transformation.
             int appCoroutine = coroutineManager.co_joinCoroutineSet(-1);
  -          CoroutineParser coParser;
  +          CoroutineParser coParser=null;
   
             if (haveXercesParser)
             {
               // CoroutineSAXParser_Xerces to avoid threading.
               // System.out.println("Using CoroutineSAXParser_Xerces to avoid 
threading");
  -            coParser = new CoroutineSAXParser_Xerces(
  -              (org.apache.xerces.parsers.SAXParser) reader, coroutineManager,
  -              appCoroutine);
  +         try {
  +           // should be ok, it's in the same package - no need for thread class 
loader
  +           Class c=Class.forName( 
"org.apache.xml.dtm.ref.CoroutineSAXParser_Xerces" );
  +           coParser=(CoroutineParser)c.newInstance();
  +           coParser.init( coroutineManager, appCoroutine, reader );
  +         }  catch( Exception ex ) {
  +           ex.printStackTrace();
  +           coParser=null;
  +         }
             }
  -          else
  -          {
  +
  +       if( coParser==null ) {
               // Create a CoroutineSAXParser that will run on the secondary thread.
               if (null == reader)
                 coParser = new CoroutineSAXParser(coroutineManager,
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to