cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@locus.apache.org
Subject cvs commit: xml-cocoon/src/org/apache/cocoon/producer AbstractProducer.java ProducerFromFile.java
Date Tue, 04 Apr 2000 11:12:50 GMT
stefano     00/04/04 04:12:50

  Modified:    src/org/apache/cocoon/producer AbstractProducer.java
                        ProducerFromFile.java
  Log:
  should fix the parsing encoding problem (bug 90)
  
  Revision  Changes    Path
  1.8       +7 -6      xml-cocoon/src/org/apache/cocoon/producer/AbstractProducer.java
  
  Index: AbstractProducer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/producer/AbstractProducer.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- AbstractProducer.java	2000/02/13 18:29:40	1.7
  +++ AbstractProducer.java	2000/04/04 11:12:49	1.8
  @@ -1,4 +1,4 @@
  -/*-- $Id: AbstractProducer.java,v 1.7 2000/02/13 18:29:40 stefano Exp $ -- 
  +/*-- $Id: AbstractProducer.java,v 1.8 2000/04/04 11:12:49 stefano Exp $ -- 
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -55,8 +55,8 @@
   import javax.servlet.http.*;
   import org.apache.cocoon.*;
   import org.apache.cocoon.parser.*;
  -import org.apache.cocoon.parser.*;
   import org.apache.cocoon.framework.*;
  +import org.xml.sax.InputSource;
   
   /**
    * This abstract class implements the Producer interface and provides
  @@ -65,12 +65,13 @@
    * seen as a transparent "mediator" between stream and DOM realms.
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version $Revision: 1.7 $ $Date: 2000/02/13 18:29:40 $
  + * @version $Revision: 1.8 $ $Date: 2000/04/04 11:12:49 $
    */
   
   public abstract class AbstractProducer extends AbstractActor implements Producer, Defaults
{
   
       protected Object context;
  +    protected Parser parser;
       
       /**
        * Initialize the producer setting its context.
  @@ -78,6 +79,7 @@
       public void init(Director director) {
           super.init(director);
           this.context = director.getActor("context");
  +        this.parser = (Parser) director.getActor("parser");
       }    
       
       /**
  @@ -89,10 +91,9 @@
        * never called directly by Cocoon.
        */
       public Document getDocument(HttpServletRequest request) throws Exception {
  -        Parser parser = (Parser) director.getActor("parser");
  -        org.xml.sax.InputSource input = new org.xml.sax.InputSource();
  +        InputSource input = new InputSource();
           input.setSystemId(this.getPath(request));
  -        input.setCharacterStream(getStream(request));
  +        input.setCharacterStream(this.getStream(request));
           return parser.parse(input);
       }
       
  
  
  
  1.8       +15 -10    xml-cocoon/src/org/apache/cocoon/producer/ProducerFromFile.java
  
  Index: ProducerFromFile.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/producer/ProducerFromFile.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ProducerFromFile.java	2000/02/13 18:29:41	1.7
  +++ ProducerFromFile.java	2000/04/04 11:12:49	1.8
  @@ -1,4 +1,4 @@
  -/*-- $Id: ProducerFromFile.java,v 1.7 2000/02/13 18:29:41 stefano Exp $ -- 
  +/*-- $Id: ProducerFromFile.java,v 1.8 2000/04/04 11:12:49 stefano Exp $ -- 
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -53,6 +53,8 @@
   import java.io.*;
   import java.net.*;
   import java.util.*;
  +import org.w3c.dom.*;
  +import org.xml.sax.*;
   import javax.servlet.*;
   import javax.servlet.http.*;
   import org.apache.cocoon.*;
  @@ -60,23 +62,26 @@
   
   /**
    * This class implements the producer interface in order to produce a document
  - * based on its tranlated path. This should work on most of the servlet engine 
  - * available, even if we should use getResource().
  + * based on its tranlated path.
    * 
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version $Revision: 1.7 $ $Date: 2000/02/13 18:29:41 $
  + * @version $Revision: 1.8 $ $Date: 2000/04/04 11:12:49 $
    */
   
   public class ProducerFromFile extends AbstractProducer implements Status {
       
       private Monitor monitor = new Monitor(10);
  -    
  -    public Reader getStream(HttpServletRequest request) throws IOException {
  -        File file = new File(Utils.getBasename(request, this.context));
  -        this.monitor.watch(Utils.encode(request), file);
  -        return new InputStreamReader(new FileInputStream(file));
  -    }
   
  +    public Document getDocument(HttpServletRequest request) throws Exception {
  +        String file = Utils.getBasename(request, this.context);
  +        this.monitor.watch(Utils.encode(request), new File(file));
  +        return parser.parse(new InputSource(file));
  +    }    
  +
  +    public Reader getStream(HttpServletRequest request) throws Exception {
  +        throw new Exception("this method should never be called!");
  +    }
  +    
       public String getPath(HttpServletRequest request) {
           String basename = Utils.getBasename(request, this.context);
           return basename.substring(0, basename.lastIndexOf('/') + 1);
  
  
  

Mime
View raw message