cziegeler    2002/10/11 01:36:30

  Modified:    src/java/org/apache/cocoon/components/pipeline
                        AbstractProcessingPipeline.java
               src/java/org/apache/cocoon/components/pipeline/impl
                        AbstractCachingProcessingPipeline.java
  Log:
  Hopefully fixing caching of readers...Thanks to Volker 
([EMAIL PROTECTED])
  
  Revision  Changes    Path
  1.24      +6 -10     
xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java
  
  Index: AbstractProcessingPipeline.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- AbstractProcessingPipeline.java   17 Sep 2002 08:09:35 -0000      1.23
  +++ AbstractProcessingPipeline.java   11 Oct 2002 08:36:30 -0000      1.24
  @@ -475,11 +475,8 @@
               if (this.checkLastModified( environment )) {
                   return true;
               }
  -            try {
  -                return this.processReader(environment, 
environment.getOutputStream(this.outputBufferSize));
  -            } catch (IOException ioe) {
  -                throw new ProcessingException("Processing of reader pipeline 
failed.", ioe);
  -            }
  +
  +            return this.processReader(environment);
           } else {
               this.setupPipeline(environment);
               this.connectPipeline(environment);
  @@ -564,8 +561,7 @@
        * Process the pipeline using a reader.
        * @throws ProcessingException if
        */
  -    protected boolean processReader(Environment environment,
  -                                    OutputStream outputStream)
  +    protected boolean processReader(Environment environment)
       throws ProcessingException {
           try {
               if (this.reader.shouldSetContentLength()) {
  @@ -574,9 +570,9 @@
                   this.reader.generate();
                   byte[] data = os.toByteArray();
                   environment.setContentLength(data.length);
  -                outputStream.write(data);
  +                environment.getOutputStream(0).write(data);
               } else {
  -                this.reader.setOutputStream(outputStream);
  +                
this.reader.setOutputStream(environment.getOutputStream(this.outputBufferSize));
                   this.reader.generate();
               }
           } catch ( SocketException se ) {
  
  
  
  1.8       +19 -5     
xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java
  
  Index: AbstractCachingProcessingPipeline.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- AbstractCachingProcessingPipeline.java    13 Sep 2002 06:46:29 -0000      1.7
  +++ AbstractCachingProcessingPipeline.java    11 Oct 2002 08:36:30 -0000      1.8
  @@ -604,7 +604,7 @@
       /** Process the pipeline using a reader.
        * @throws ProcessingException if an error occurs
        */
  -    protected boolean processReader(Environment environment)
  +    protected boolean processReader(Environment  environment)
       throws ProcessingException {
           try {
               boolean usedCache = false;
  @@ -706,10 +706,24 @@
                       }
                   }
   
  -                if (outputStream == null) {
  -                    outputStream = 
environment.getOutputStream(this.outputBufferSize);
  +
  +                if (this.reader.shouldSetContentLength()) {
  +                    ByteArrayOutputStream os = new ByteArrayOutputStream();
  +                    this.reader.setOutputStream(os);
  +                    this.reader.generate();
  +                    byte[] data = os.toByteArray();
  +                    environment.setContentLength(data.length);
  +                    if (outputStream == null) {
  +                        outputStream = environment.getOutputStream(0);
  +                    }
  +                    environment.getOutputStream(0).write(data);
  +                } else {
  +                    if (outputStream == null) {
  +                        outputStream = 
environment.getOutputStream(this.outputBufferSize);
  +                    }
  +                    this.reader.setOutputStream(outputStream);
  +                    this.reader.generate();
                   }
  -                super.processReader( environment, outputStream );
   
                   // store the response
                   if (pcKey != null) {
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to