You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by vg...@apache.org on 2005/03/12 13:28:51 UTC
svn commit: r157250 - in
cocoon/trunk/src/java/org/apache/cocoon/components/pipeline:
AbstractProcessingPipeline.java ProcessingPipeline.java
Author: vgritsenko
Date: Sat Mar 12 04:28:49 2005
New Revision: 157250
URL: http://svn.apache.org/viewcvs?view=rev&rev=157250
Log:
whitespaces, etc
Modified:
cocoon/trunk/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java
cocoon/trunk/src/java/org/apache/cocoon/components/pipeline/ProcessingPipeline.java
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java?view=diff&r1=157249&r2=157250
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java Sat Mar 12 04:28:49 2005
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -61,8 +61,8 @@
* @version CVS $Id$
*/
public abstract class AbstractProcessingPipeline
- extends AbstractLogEnabled
- implements ProcessingPipeline, Parameterizable, Recyclable, Serviceable {
+ extends AbstractLogEnabled
+ implements ProcessingPipeline, Parameterizable, Recyclable, Serviceable {
// Generator stuff
protected Generator generator;
@@ -86,14 +86,12 @@
protected String readerSource;
protected String readerMimeType;
- /**
- * True when pipeline has been prepared.
- */
+ /** True when pipeline has been prepared. */
private boolean prepared;
/**
* This is the last component in the pipeline, either the serializer
- * or a custom xmlconsumer for the cocoon: protocol etc.
+ * or a custom XML consumer in case of internal processing.
*/
protected XMLConsumer lastConsumer;
@@ -106,20 +104,20 @@
/** The configuration */
protected Parameters configuration;
- /** The parameters */
- protected Parameters parameters;
-
- /** Expires value */
- protected long expires;
-
/** Configured Expires value */
protected long configuredExpires;
/** Configured Output Buffer Size */
protected int configuredOutputBufferSize;
+ /** The parameters */
+ protected Parameters parameters;
+
+ /** Expires value */
+ protected long expires;
+
/** Output Buffer Size */
- protected int outputBufferSize;
+ protected int outputBufferSize;
/** The current Processor */
protected Processor processor;
@@ -169,18 +167,18 @@
}
/**
- * Get the generator - used for content aggregation
+ * Informs pipeline we have come across a branch point.
+ * Default behaviour is do nothing.
*/
- public Generator getGenerator() {
- return this.generator;
+ public void informBranchPoint() {
+ // this can be overwritten in subclasses
}
/**
- * Informs pipeline we have come across a branch point
- * Default Behaviour is do nothing
+ * Get the generator - used for content aggregation
*/
- public void informBranchPoint() {
- // this can be overwritten in subclasses
+ public Generator getGenerator() {
+ return this.generator;
}
/**
@@ -198,11 +196,11 @@
throws ProcessingException {
if (this.generator != null) {
throw new ProcessingException ("Generator already set. Cannot set generator '" + role +
- "' at " + getLocation(param));
+ "' at " + getLocation(param));
}
if (this.reader != null) {
throw new ProcessingException ("Reader already set. Cannot set generator '" + role +
- "' at " + getLocation(param));
+ "' at " + getLocation(param));
}
try {
this.generator = (Generator) this.newManager.lookup(Generator.ROLE + '/' + role);
@@ -229,11 +227,11 @@
if (this.reader != null) {
// Should normally never happen as setting a reader starts pipeline processing
throw new ProcessingException ("Reader already set. Cannot add transformer '" + role +
- "' at " + getLocation(param));
+ "' at " + getLocation(param));
}
if (this.generator == null) {
throw new ProcessingException ("Must set a generator before adding transformer '" + role +
- "' at " + getLocation(param));
+ "' at " + getLocation(param));
}
try {
this.transformers.add(this.newManager.lookup(Transformer.ROLE + '/' + role));
@@ -253,16 +251,16 @@
if (this.serializer != null) {
// Should normally not happen as adding a serializer starts pipeline processing
throw new ProcessingException ("Serializer already set. Cannot set serializer '" + role +
- "' at " + getLocation(param));
+ "' at " + getLocation(param));
}
if (this.reader != null) {
// Should normally never happen as setting a reader starts pipeline processing
throw new ProcessingException ("Reader already set. Cannot set serializer '" + role +
- "' at " + getLocation(param));
+ "' at " + getLocation(param));
}
if (this.generator == null) {
throw new ProcessingException ("Must set a generator before setting serializer '" + role +
- "' at " + getLocation(param));
+ "' at " + getLocation(param));
}
try {
@@ -285,12 +283,12 @@
if (this.reader != null) {
// Should normally never happen as setting a reader starts pipeline processing
throw new ProcessingException ("Reader already set. Cannot set reader '" + role +
- "' at " + getLocation(param));
+ "' at " + getLocation(param));
}
if (this.generator != null) {
// Should normally never happen as setting a reader starts pipeline processing
throw new ProcessingException ("Generator already set. Cannot use reader '" + role +
- "' at " + getLocation(param));
+ "' at " + getLocation(param));
}
try {
@@ -303,6 +301,7 @@
this.readerMimeType = mimeType;
}
+
/**
* Sanity check
* @return true if the pipeline is 'sane', false otherwise.
@@ -453,8 +452,8 @@
}
/**
- * Prepare an internal processing
- * @param environment The current environment.
+ * Prepare an internal processing.
+ * @param environment The current environment.
* @throws ProcessingException
*/
public void prepareInternal(Environment environment)
@@ -470,7 +469,6 @@
throws ProcessingException {
setMimeTypeForSerializer(environment);
-
try {
if (this.lastConsumer == null) {
// internal processing
@@ -498,6 +496,7 @@
// TODO: Unwrap SAXException ?
throw new ProcessingException("Failed to execute pipeline.", e);
}
+
return true;
}
@@ -537,12 +536,15 @@
// the reader can use MIME type declared in WEB-INF/web.xml or
// by the server.
if ( this.readerMimeType != null ) {
+ // there was a mime-type defined on map:read in the sitemap
environment.setContentType(this.readerMimeType);
} else {
final String mimeType = this.reader.getMimeType();
if (mimeType != null) {
environment.setContentType(mimeType);
}
+ // If no mimeType available, leave to to upstream proxy
+ // or browser to deduce content-type from URL extension.
}
}
@@ -577,7 +579,7 @@
}
protected boolean checkIfModified(Environment environment,
- long lastModified)
+ long lastModified)
throws ProcessingException {
// has the read resource been modified?
if(!environment.isResponseModified(lastModified)) {
@@ -652,7 +654,7 @@
/**
* Process the given <code>Environment</code>, but do not use the
- * serializer. Instead the sax events are streamed to the XMLConsumer.
+ * serializer. Instead all SAX events are streamed to the XMLConsumer.
*/
public boolean process(Environment environment, XMLConsumer consumer)
throws ProcessingException {
@@ -660,6 +662,7 @@
if (this.reader != null) {
throw new ProcessingException("Streaming of an internal pipeline is not possible with a reader.");
}
+
connectPipeline(environment);
return processXMLPipeline(environment);
}
@@ -675,6 +678,17 @@
}
/**
+ * Return the key for the event pipeline
+ * If the "event pipeline" (= the complete pipeline without the
+ * serializer) is cacheable and valid, return a key.
+ * Otherwise return <code>null</code>
+ */
+ public String getKeyForEventPipeline() {
+ return null;
+ }
+
+
+ /**
* Parse the expires parameter
*/
private long parseExpires(String expire) {
@@ -744,13 +758,6 @@
}
return expires;
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.components.pipeline.ProcessingPipeline#getKeyForEventPipeline()
- */
- public String getKeyForEventPipeline() {
- return null;
}
protected String getLocation(Parameters param) {
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/pipeline/ProcessingPipeline.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/pipeline/ProcessingPipeline.java?view=diff&r1=157249&r2=157250
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/pipeline/ProcessingPipeline.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/pipeline/ProcessingPipeline.java Sat Mar 12 04:28:49 2005
@@ -1,12 +1,12 @@
/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
+ * Copyright 1999-2005 The Apache Software Foundation.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,36 +17,36 @@
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.service.ServiceManager;
+
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.environment.Environment;
import org.apache.cocoon.generation.Generator;
import org.apache.cocoon.xml.XMLConsumer;
+
import org.apache.excalibur.source.SourceValidity;
/**
* A <code>ProcessingPipeline<code> produces the response for a given request.
* It is assembled according to the commands in the sitemap and can either
* <ul>
- * <li>collect a <code>Reader</code> and let it produce a character stream</li>
- * <li>or connect a <code>Generator</code> with zero or more
- * <code>Transformer</code>s and a <code>Serializer</code> and let them
+ * <li>Collect a <code>Reader</code> and let it produce a byte stream,</li>
+ * <li>Or connect a <code>Generator</code> with zero or more
+ * <code>Transformer</code>s and a <code>Serializer</code>, and let them
* produce the byte stream. This pipeline uses SAX events for
* communication.
* </li>
* </ul>
*
- * <p>
- *
- * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
+= * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
* @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
- * @version CVS $Id$
+ * @version $Id$
*/
public interface ProcessingPipeline {
String ROLE = ProcessingPipeline.class.getName();
/**
- * Setup this component
+ * Setup this component.
*/
void setup(Parameters params);
@@ -61,7 +61,7 @@
* @param param the parameters for the generator.
* @throws ProcessingException if the generator couldn't be obtained.
*/
- void setGenerator (String role, String source, Parameters param, Parameters hintParam)
+ void setGenerator(String role, String source, Parameters param, Parameters hintParam)
throws ProcessingException;
/**
@@ -73,7 +73,7 @@
* Informs pipeline we have come across a branch point
*/
void informBranchPoint();
-
+
/**
* Set the <code>ServiceManager</code> where pipeline components have to be searched for.
* @param manager the processor's service manager.
@@ -91,21 +91,21 @@
* @param param the parameters for the transfomer.
* @throws ProcessingException if the generator couldn't be obtained.
*/
- void addTransformer (String role, String source, Parameters param, Parameters hintParam)
+ void addTransformer(String role, String source, Parameters param, Parameters hintParam)
throws ProcessingException;
/**
* Set the serializer for this pipeline
* @param mimeType Can be null
*/
- void setSerializer (String role, String source, Parameters param, Parameters hintParam, String mimeType)
+ void setSerializer(String role, String source, Parameters param, Parameters hintParam, String mimeType)
throws ProcessingException;
/**
* Set the reader for this pipeline
* @param mimeType Can be null
*/
- void setReader (String role, String source, Parameters param, String mimeType)
+ void setReader(String role, String source, Parameters param, String mimeType)
throws ProcessingException;
/**
@@ -137,7 +137,7 @@
* Otherwise return <code>null</code>
*/
SourceValidity getValidityForEventPipeline();
-
+
/**
* Return the key for the event pipeline
* If the "event pipeline" (= the complete pipeline without the