You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by gr...@apache.org on 2001/02/24 19:20:42 UTC

cvs commit: xml-cocoon/src/org/apache/cocoon Cocoon.java EngineWrapper.java

greenrd     01/02/24 10:20:42

  Modified:    .        changes.xml
               src/org/apache/cocoon Cocoon.java EngineWrapper.java
  Log:
  fixed cmdline mode, thanks nick - we could really use some automated impact analysis or regression testing to catch stuff like this
  
  Revision  Changes    Path
  1.210     +4 -1      xml-cocoon/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/changes.xml,v
  retrieving revision 1.209
  retrieving revision 1.210
  diff -u -r1.209 -r1.210
  --- changes.xml	2001/02/19 20:06:02	1.209
  +++ changes.xml	2001/02/24 18:20:42	1.210
  @@ -4,7 +4,7 @@
   
   <!--
     History of Cocoon changes   
  -  $Id: changes.xml,v 1.209 2001/02/19 20:06:02 greenrd Exp $ 
  +  $Id: changes.xml,v 1.210 2001/02/24 18:20:42 greenrd Exp $ 
   -->
   
   <changes title="History of Changes">
  @@ -18,6 +18,9 @@
     </devs>
   
    <release version="@version@" date="@date@">
  +  <action dev="RDG" type="fix" due-to="Nicol�s Lichtmaier" due-to-email="nick@debian.org">
  +   Fixed command-line mode (again!)
  +  </action>
     <action dev="RDG" type="fix" fixes-bug="642" due-to="Antonia Arena" due-to-email="antonio_arena@yahoo.it">
      Fixed bug in Util.getAllPIs
     </action>
  
  
  
  1.22      +6 -6      xml-cocoon/src/org/apache/cocoon/Cocoon.java
  
  Index: Cocoon.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Cocoon.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- Cocoon.java	2001/01/18 22:43:45	1.21
  +++ Cocoon.java	2001/02/24 18:20:42	1.22
  @@ -1,4 +1,4 @@
  -/*-- $Id: Cocoon.java,v 1.21 2001/01/18 22:43:45 greenrd Exp $ -- 
  +/*-- $Id: Cocoon.java,v 1.22 2001/02/24 18:20:42 greenrd Exp $ -- 
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -64,7 +64,7 @@
    * separate different knowledge contexts in different processing layers.
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version $Revision: 1.21 $ $Date: 2001/01/18 22:43:45 $
  + * @version $Revision: 1.22 $ $Date: 2001/02/24 18:20:42 $
    */
   
   public class Cocoon extends HttpServlet implements Defaults {
  @@ -269,7 +269,7 @@
           String userAgent = null;
           String xml = null;
           String out = null;
  -        PrintWriter writer = null;
  +        OutputStream out = null;
           Configurations confs = null;
   
           if (argument.length == 0)
  @@ -305,10 +305,10 @@
   
           EngineWrapper engine = new EngineWrapper(confs);
           if (out == null)
  -          writer = new PrintWriter(System.out);
  +          os = System.out;
           else
  -          writer = new PrintWriter(new FileWriter(out), true);
  -        engine.handle(writer, new File(xml));
  +          os = new FileOutputStream(out);
  +        engine.handle(os, new File(xml));
       }
   
       private static void usage() {
  
  
  
  1.14      +22 -8     xml-cocoon/src/org/apache/cocoon/EngineWrapper.java
  
  Index: EngineWrapper.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/EngineWrapper.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- EngineWrapper.java	2001/01/11 13:52:19	1.13
  +++ EngineWrapper.java	2001/02/24 18:20:42	1.14
  @@ -1,4 +1,4 @@
  -/*-- $Id: EngineWrapper.java,v 1.13 2001/01/11 13:52:19 greenrd Exp $ -- 
  +/*-- $Id: EngineWrapper.java,v 1.14 2001/02/24 18:20:42 greenrd Exp $ -- 
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -70,7 +70,7 @@
    * But I have more important stuff to do right now.
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version $Revision: 1.13 $ $Date: 2001/01/11 13:52:19 $
  + * @version $Revision: 1.14 $ $Date: 2001/02/24 18:20:42 $
    */
   
   public class EngineWrapper {
  @@ -83,11 +83,11 @@
           this.userAgent = (String)confs.get("user-agent");
       }
   
  -    public void handle(PrintWriter out, File pathToDocument) throws Exception {
  +    public void handle(OutputStream out, File pathToDocument) throws Exception {
           this.engine.handle(new HttpServletRequestImpl(pathToDocument), new HttpServletResponseImpl(out));
       }
   
  -    public void handle(PrintWriter out, File documentPath, String document) throws Exception {
  +    public void handle(OutputStream out, File documentPath, String document) throws Exception {
           this.engine.handle(new HttpServletRequestImpl(documentPath, document), new HttpServletResponseImpl(out));
       }
   
  @@ -188,19 +188,33 @@
        */
       public class HttpServletResponseImpl implements HttpServletResponse {
           
  -        private PrintWriter out;
  +        private OutputStream out;
           
  -        public HttpServletResponseImpl(PrintWriter out) {
  +        public HttpServletResponseImpl(OutputStream out) {
               this.out = out;
           }
   
           public PrintWriter getWriter() throws IOException {
  -            return this.out;
  +            return new PrintWriter(new OutputStreamWriter(this.out));
           }
  +
  +        public ServletOutputStream getOutputStream() throws IOException {
  +            return new ServletOutputStream()
  +            {
  +                public void write(int c) throws IOException
  +                {
  +                    out.write(c);
  +                }
  +                public void write(byte[] b, int off, int len)
  +                    throws IOException
  +               {
  +                    out.write(b,off,len);
  +                }
  +            };
  +        }
           
           public void setContentLength(int len) {}
           public void setContentType(String type) {}
  -        public ServletOutputStream getOutputStream() throws IOException { return null; }
           public String getCharacterEncoding() { return null; }
           public void addCookie(Cookie cookie) {}
           public boolean containsHeader(String name) { return false; }