jakarta-ecs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sn...@apache.org
Subject cvs commit: jakarta-ecs/src/java/org/apache/ecs/factory DOMFactory.java
Date Fri, 22 Jun 2001 19:43:33 GMT
snagy       01/06/22 12:43:33

  Modified:    example  TestBed.java
               src/java/org/apache/ecs/factory DOMFactory.java
  Log:
  Submitted by: rajeswarir@ionidea.com
  
  Change DOMFactory so that it doesn't use Piped*Streams as they can deadlock,
  and I don't have enough time to figure out how your supposed to use them to
  prevent the deadlock.
  
  -stephan
  
  Revision  Changes    Path
  1.16      +12 -12    jakarta-ecs/example/TestBed.java
  
  Index: TestBed.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ecs/example/TestBed.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- TestBed.java	2001/06/12 23:22:31	1.15
  +++ TestBed.java	2001/06/22 19:43:31	1.16
  @@ -72,7 +72,7 @@
       Pass the method name if you want that to be tested
       or 'all' to call all test methods in turn.
   
  -    @version $Id: TestBed.java,v 1.15 2001/06/12 23:22:31 snagy Exp $
  +    @version $Id: TestBed.java,v 1.16 2001/06/22 19:43:31 snagy Exp $
       @author <a href="mailto:snagy@servletapi.com">Stephan Nagy</a>
       @author <a href="mailto:jon@clearink.com">Jon S. Stevens</a>
   */
  @@ -1009,11 +1009,11 @@
           org.apache.ecs.factory.DOMFactory d = new org.apache.ecs.factory.DOMFactory();
           p.output(d.getOutputStream());
   
  -        //NodeList nl = d.createDOM();
  -        //for(int a = 0; a < nl.getLength(); a++)
  -        //{
  -        //   traverse(nl.item(a));
  -        //}
  +        NodeList nl = d.createDOM().getChildNodes();
  +        for(int a = 0; a < nl.getLength(); a++)
  +        {
  +           traverse(nl.item(a));
  +        }
       }
   
       private static void traverse(Node node)
  @@ -1115,7 +1115,7 @@
       this method prints up the usage.
       */
       private static void printUsage(TestBed instance)
  -    {            
  +    {
           System.out.println("TesBed usage:");
           System.out.println("\tjava TestBed all");
           System.out.println("OR");
  @@ -1139,7 +1139,7 @@
       if you want this method to find them!)
       */
       private static void testAll(TestBed instance)
  -    {            
  +    {
           java.lang.reflect.Method[] methods= instance.getClass().getMethods();
           for (int i=0; i<methods.length;i++)
           {
  @@ -1147,7 +1147,7 @@
               {
                   System.out.println();
                   System.out.println(methods[i].getName()+":");
  -                try { 
  +                try {
                       methods[i].invoke(instance,new Class[]{});
                   } catch (Exception ex) {
                       ex.printStackTrace();
  @@ -1155,12 +1155,12 @@
               }
           }
       }
  -    
  +
       /**
       pass a single parameter to this class.
       for example <code> java TestBed arg</code> where <code>arg</code>
       is either <code>all</code> (which will call every test method in this class
in turn)
  -    or <code><method></code> (which calls the test method called <method>
in this class). 
  +    or <code><method></code> (which calls the test method called <method>
in this class).
       */
       public static void main(String[] args)
       {
  @@ -1174,7 +1174,7 @@
               {
                   testAll(tb);
               } else {
  -                try { 
  +                try {
                       java.lang.reflect.Method meth=tb.getClass().getMethod(method, new Class[]{});
                       meth.invoke(tb,new Class[]{});
                   } catch (NoSuchMethodException ex) {
  
  
  
  1.8       +7 -18     jakarta-ecs/src/java/org/apache/ecs/factory/DOMFactory.java
  
  Index: DOMFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ecs/src/java/org/apache/ecs/factory/DOMFactory.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DOMFactory.java	2000/12/05 21:54:58	1.7
  +++ DOMFactory.java	2001/06/22 19:43:33	1.8
  @@ -53,29 +53,17 @@
   
   package org.apache.ecs.factory;
   
  -import java.io.PipedInputStream;
  -import java.io.PipedOutputStream;
  +import java.io.StringReader;
  +import java.io.ByteArrayOutputStream;
  +import java.io.OutputStream;
   
   import org.apache.xerces.parsers.DOMParser;
   import org.w3c.dom.Document;
   
   public class DOMFactory
   {
  -    private PipedOutputStream outStream = new PipedOutputStream();
  -    private PipedInputStream pis = null;
  +    private ByteArrayOutputStream outStream = new ByteArrayOutputStream();
   
  -    /* Default Initializer */
  -    {
  -        try
  -        {
  -            pis = new PipedInputStream(outStream);
  -        }
  -        catch(java.io.IOException _e)
  -        {
  -            throw new InternalError(_e.toString());
  -        }
  -    }
  -
       /**
         Default Constructor.  Here is a simple example on how to use this class.
         <code>
  @@ -104,7 +92,7 @@
       /**
         Gets the output stream for the ecs element to write to.
       */
  -    public PipedOutputStream getOutputStream()
  +    public OutputStream getOutputStream()
       {
           return outStream;
       }
  @@ -120,8 +108,9 @@
           try
           {
               outStream.close(); // before we parse the InputStream make sure the pipe is
closed.
  +            StringReader reader = new StringReader(outStream.toString());
               parser = new DOMParser();
  -            parser.parse(new org.xml.sax.InputSource(pis));
  +            parser.parse(new org.xml.sax.InputSource(reader));
               doc = parser.getDocument();
           }
           catch(java.io.IOException ioe)
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ecs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: ecs-dev-help@jakarta.apache.org


Mime
View raw message