cziegeler 02/05/03 04:55:05
Modified: src/java/org/apache/cocoon/caching CachedEventObject.java
src/java/org/apache/cocoon/components/pipeline
AbstractProcessingPipeline.java
ProcessingPipeline.java
Added: src/java/org/apache/cocoon/caching
CacheableProcessingComponent.java
Log:
Minor update for processing pipeline
Revision Changes Path
1.7 +2 -2
xml-cocoon2/src/java/org/apache/cocoon/caching/CachedEventObject.java
Index: CachedEventObject.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/caching/CachedEventObject.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- CachedEventObject.java 22 Feb 2002 07:03:49 -0000 1.6
+++ CachedEventObject.java 3 May 2002 11:55:05 -0000 1.7
@@ -53,10 +53,10 @@
import java.util.Map;
/**
- * This is an cached object as it is stored in the <code>EventCache</code>
+ * This is a cached object as it is stored in the <code>EventCache</code>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
- * @version CVS $Id: CachedEventObject.java,v 1.6 2002/02/22 07:03:49 cziegeler Exp
$
+ * @version CVS $Id: CachedEventObject.java,v 1.7 2002/05/03 11:55:05 cziegeler Exp
$
*/
public final class CachedEventObject implements java.io.Serializable {
1.1
xml-cocoon2/src/java/org/apache/cocoon/caching/CacheableProcessingComponent.java
Index: CacheableProcessingComponent.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.caching;
import org.apache.excalibur.source.SourceValidity;
/**
* This marker interface declares a (sitemap) component as cacheable.
*
* This interface deprecates the org.apache.cocoon.caching.Cacheable interface!
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
* @version CVS $Id: CacheableProcessingComponent.java,v 1.1 2002/05/03 11:55:05
cziegeler Exp $
*/
public interface CacheableProcessingComponent {
/**
* Generate the unique key.
* This key must be unique inside the space of this component.
* This method must be invoked before the generateValidity() method.
*
* @return The generated key or <code>0</code> if the component
* is currently not cacheable.
*/
long generateKey();
/**
* Generate the validity object.
* Before this method can be invoked the generateKey() method
* must be invoked.
*
* @return The generated validity object or <code>null</code> if the
* component is currently not cacheable.
*/
SourceValidity generateValidity();
}
1.5 +29 -13
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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AbstractProcessingPipeline.java 3 May 2002 10:59:01 -0000 1.4
+++ AbstractProcessingPipeline.java 3 May 2002 11:55:05 -0000 1.5
@@ -55,7 +55,7 @@
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.component.ComponentSelector;
-import org.apache.avalon.framework.logger.AbstractLoggable;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.components.pipeline.OutputComponentSelector;
@@ -65,7 +65,6 @@
import org.apache.cocoon.reading.Reader;
import org.apache.cocoon.serialization.Serializer;
import org.apache.cocoon.transformation.Transformer;
-import org.apache.cocoon.xml.AbstractXMLProducer;
import org.apache.cocoon.xml.XMLConsumer;
import org.apache.cocoon.xml.XMLProducer;
import org.xml.sax.SAXException;
@@ -78,10 +77,10 @@
* This is the base for all implementations of a <code>ProcessingPipeline</code>.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
- * @version CVS $Id: AbstractProcessingPipeline.java,v 1.4 2002/05/03 10:59:01
cziegeler Exp $
+ * @version CVS $Id: AbstractProcessingPipeline.java,v 1.5 2002/05/03 11:55:05
cziegeler Exp $
*/
public abstract class AbstractProcessingPipeline
- extends AbstractLoggable
+ extends AbstractLogEnabled
implements ProcessingPipeline, Recyclable {
// Generator stuff
@@ -112,6 +111,11 @@
protected String sitemapReaderMimeType;
protected OutputComponentSelector readerSelector;
+ /** This is the last component in the pipeline, either the serializer
+ * or a custom xmlconsumer for the cocoon: protocol etc.
+ */
+ protected XMLConsumer lastConsumer;
+
// The SAX Connectors
protected ArrayList connectors = new ArrayList();
@@ -181,13 +185,6 @@
}
/**
- * Get the current Generator
- */
- public Generator getGenerator() {
- return this.generator;
- }
-
- /**
* Add a transformer at the end of the pipeline.
* The transformer role is given : the actual <code>Transformer</code> is
fetched
* from the latest <code>ComponentManager</code> given by <code>compose()</code>
@@ -253,6 +250,7 @@
this.serializerParam = param;
this.serializerMimeType = mimeType;
this.sitemapSerializerMimeType =
serializerSelector.getMimeTypeForHint(role);
+ this.lastConsumer = this.serializer;
}
/**
@@ -395,7 +393,7 @@
prev = connect;
}
// insert the serializer
- prev.setConsumer(this.serializer);
+ prev.setConsumer(this.lastConsumer);
} catch ( IOException e ) {
throw new ProcessingException(
"Could not connect pipeline.",
@@ -558,9 +556,9 @@
this.serializerSelector.release(this.serializer);
this.newManager.release( this.serializerSelector );
this.serializerSelector = null;
- this.serializer = null;
this.serializerParam = null;
}
+ this.serializer = null;
// Release connectors
Iterator itc = this.connectors.iterator();
@@ -571,4 +569,22 @@
this.parameters = null;
}
+
+ /**
+ * Process the given <code>Environment</code>, but do not use the
+ * serializer. Instead the sax events are streamed to the XMLConsumer.
+ */
+ public boolean process(Environment environment, XMLConsumer consumer)
+ throws ProcessingException {
+ if ( !checkPipeline() ) {
+ throw new ProcessingException("Attempted to process incomplete
pipeline.");
+ }
+ if ( this.reader != null ) {
+ // FIXME (CZ) We *could* use the xmlizer here...but does this make
sense?!?
+ throw new ProcessingException("Streaming of pipeline is not possible
with a reader.");
+ }
+ this.lastConsumer = consumer;
+ return this.process( environment );
+ }
+
}
1.3 +8 -10
xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/ProcessingPipeline.java
Index: ProcessingPipeline.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/ProcessingPipeline.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ProcessingPipeline.java 2 May 2002 14:20:46 -0000 1.2
+++ ProcessingPipeline.java 3 May 2002 11:55:05 -0000 1.3
@@ -55,6 +55,7 @@
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.environment.Environment;
+import org.apache.cocoon.xml.XMLConsumer;
/**
* A <code>ProcessingPipeline<code> produces the response for a given request.
@@ -76,7 +77,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Id: ProcessingPipeline.java,v 1.2 2002/05/02 14:20:46 cziegeler
Exp $
+ * @version CVS $Id: ProcessingPipeline.java,v 1.3 2002/05/03 11:55:05 cziegeler
Exp $
*/
public interface ProcessingPipeline
extends Component, Recomposable {
@@ -99,15 +100,6 @@
throws ProcessingException;
/**
- * Get the generator used by this pipeline. Access to the generator is needed
for
- * content aggregation since the aggregation generator is fed by the pipeline
engine
- * with the different parts.
- *
- * @return the generator
- Generator getGenerator ();
- */
-
- /**
* Add a transformer at the end of the pipeline.
* The transformer role is given : the actual <code>Transformer</code> is
fetched
* from the latest <code>ComponentManager</code> given by <code>compose()</code>
@@ -148,4 +140,10 @@
boolean process(Environment environment)
throws ProcessingException;
+ /**
+ * Process the given <code>Environment</code>, but do not use the
+ * serializer. Instead the sax events are streamed to the XMLConsumer.
+ */
+ boolean process(Environment environment, XMLConsumer consumer)
+ throws ProcessingException;
}
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]