org.apache.cocoon.components.pipeline
Class AbstractProcessingPipeline

java.lang.Object
  extended byorg.apache.cocoon.util.AbstractLogEnabled
      extended byorg.apache.cocoon.components.pipeline.AbstractProcessingPipeline
All Implemented Interfaces:
Parameterizable, Poolable, org.apache.cocoon.components.pipeline.ProcessingPipeline, Recyclable, Serviceable
Direct Known Subclasses:
BaseCachingProcessingPipeline, NonCachingProcessingPipeline

public abstract class AbstractProcessingPipeline
extends org.apache.cocoon.util.AbstractLogEnabled
implements org.apache.cocoon.components.pipeline.ProcessingPipeline, Parameterizable, Recyclable, Serviceable

This is the base for all implementations of a ProcessingPipeline. It is advisable to inherit from this base class instead of doing a complete own implementation!

Since:
2.1
Version:
$Id: AbstractProcessingPipeline.html 1304280 2012-03-23 11:18:01Z ilgrosso $

Field Summary
protected  Parameters configuration
          The configuration
protected  long configuredExpires
          Configured Expires value
protected  int configuredOutputBufferSize
          Configured Output Buffer Size
protected  long expires
          Expires value
protected  org.apache.cocoon.generation.Generator generator
           
protected  Parameters generatorParam
           
protected  String generatorSource
           
protected  org.apache.cocoon.xml.XMLConsumer lastConsumer
          This is the last component in the pipeline, either the serializer or a custom XML consumer in case of internal processing.
protected  ServiceManager manager
          The component manager set with compose()
protected  ServiceManager newManager
          The component manager set with compose() and recompose()
protected  int outputBufferSize
          Output Buffer Size
protected  Parameters parameters
          The parameters
protected  org.apache.cocoon.reading.Reader reader
           
protected  String readerMimeType
           
protected  Parameters readerParam
           
protected  String readerSource
           
protected  org.apache.cocoon.serialization.Serializer serializer
           
protected  String serializerMimeType
           
protected  Parameters serializerParam
           
protected  String serializerSource
           
protected  org.apache.cocoon.environment.SourceResolver sourceResolver
          The current SourceResolver
protected  ArrayList transformerParams
           
protected  ArrayList transformers
           
protected  ArrayList transformerSources
           
 
Fields inherited from interface org.apache.cocoon.components.pipeline.ProcessingPipeline
ROLE
 
Constructor Summary
AbstractProcessingPipeline()
           
 
Method Summary
 void addTransformer(String role, String source, Parameters param, Parameters hintParam)
          Add a transformer at the end of the pipeline.
protected  boolean checkIfModified(org.apache.cocoon.environment.Environment environment, long lastModified)
           
protected  boolean checkPipeline()
          Sanity check
protected  void connect(org.apache.cocoon.environment.Environment environment, org.apache.cocoon.xml.XMLProducer producer, org.apache.cocoon.xml.XMLConsumer consumer)
          Connect the next component
protected  void connectPipeline(org.apache.cocoon.environment.Environment environment)
          Connect the XML pipeline.
 org.apache.cocoon.generation.Generator getGenerator()
          Get the generator - used for content aggregation
 String getKeyForEventPipeline()
          Return the key for the event pipeline If the "event pipeline" (= the complete pipeline without the serializer) is cacheable and valid, return a key.
protected  org.apache.cocoon.util.location.Location getLocation(Parameters param)
           
 SourceValidity getValidityForEventPipeline()
          Return valid validity objects for the event pipeline If the "event pipeline" (= the complete pipeline without the serializer) is cacheable and valid, return all validity objects.
protected  void handleException(Exception e)
          Handles exception which can happen during pipeline processing.
 void informBranchPoint()
          Informs pipeline we have come across a branch point.
protected  boolean isInternalError()
           
 void parameterize(Parameters params)
          Parameterizable Interface - Configuration
 void prepareInternal(org.apache.cocoon.environment.Environment environment)
          Prepare an internal processing.
protected  void prepareInternalErrorHandler(org.apache.cocoon.environment.Environment environment, org.apache.cocoon.ProcessingException ex)
          If prepareInternal fails, prepare internal error handler.
protected  void preparePipeline(org.apache.cocoon.environment.Environment environment)
          Prepare the pipeline
 boolean process(org.apache.cocoon.environment.Environment environment)
          Process the given Environment, producing the output.
 boolean process(org.apache.cocoon.environment.Environment environment, org.apache.cocoon.xml.XMLConsumer consumer)
          Process the given Environment, but do not use the serializer.
protected  boolean processErrorHandler(org.apache.cocoon.environment.Environment environment, org.apache.cocoon.ProcessingException e, org.apache.cocoon.xml.XMLConsumer consumer)
           
protected  boolean processReader(org.apache.cocoon.environment.Environment environment)
          Process the pipeline using a reader.
protected  boolean processXMLPipeline(org.apache.cocoon.environment.Environment environment)
          Process the SAX event pipeline
 void recycle()
           
 void service(ServiceManager aManager)
           
 void setErrorHandler(org.apache.cocoon.sitemap.SitemapErrorHandler errorHandler)
          Sets error handler for this pipeline.
 void setGenerator(String role, String source, Parameters param, Parameters hintParam)
          Set the generator that will be used as the initial step in the pipeline.
protected  void setMimeTypeForReader(org.apache.cocoon.environment.Environment environment)
          Set the mime-type for a reader
protected  void setMimeTypeForSerializer(org.apache.cocoon.environment.Environment environment)
          Set the mime-type for a serializer
 void setProcessorManager(ServiceManager manager)
          Set the processor's service manager
 void setReader(String role, String source, Parameters param, String mimeType)
          Set the reader for this pipeline
 void setSerializer(String role, String source, Parameters param, Parameters hintParam, String mimeType)
          Set the serializer for this pipeline
 void setup(Parameters params)
          Setup this component
protected  void setupPipeline(org.apache.cocoon.environment.Environment environment)
          Setup pipeline components.
protected  void setupReader(org.apache.cocoon.environment.Environment environment)
          Setup the reader
 
Methods inherited from class org.apache.cocoon.util.AbstractLogEnabled
getLogger, setLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

generator

protected org.apache.cocoon.generation.Generator generator

generatorParam

protected Parameters generatorParam

generatorSource

protected String generatorSource

transformers

protected ArrayList transformers

transformerParams

protected ArrayList transformerParams

transformerSources

protected ArrayList transformerSources

serializer

protected org.apache.cocoon.serialization.Serializer serializer

serializerParam

protected Parameters serializerParam

serializerSource

protected String serializerSource

serializerMimeType

protected String serializerMimeType

reader

protected org.apache.cocoon.reading.Reader reader

readerParam

protected Parameters readerParam

readerSource

protected String readerSource

readerMimeType

protected String readerMimeType

lastConsumer

protected org.apache.cocoon.xml.XMLConsumer lastConsumer
This is the last component in the pipeline, either the serializer or a custom XML consumer in case of internal processing.


manager

protected ServiceManager manager
The component manager set with compose()


newManager

protected ServiceManager newManager
The component manager set with compose() and recompose()


configuration

protected Parameters configuration
The configuration


configuredExpires

protected long configuredExpires
Configured Expires value


configuredOutputBufferSize

protected int configuredOutputBufferSize
Configured Output Buffer Size


parameters

protected Parameters parameters
The parameters


expires

protected long expires
Expires value


outputBufferSize

protected int outputBufferSize
Output Buffer Size


sourceResolver

protected org.apache.cocoon.environment.SourceResolver sourceResolver
The current SourceResolver

Constructor Detail

AbstractProcessingPipeline

public AbstractProcessingPipeline()
Method Detail

service

public void service(ServiceManager aManager)
             throws ServiceException
Specified by:
service in interface Serviceable
Throws:
ServiceException
See Also:
Serviceable.service(org.apache.avalon.framework.service.ServiceManager)

setProcessorManager

public void setProcessorManager(ServiceManager manager)
Set the processor's service manager

Specified by:
setProcessorManager in interface org.apache.cocoon.components.pipeline.ProcessingPipeline

parameterize

public void parameterize(Parameters params)
                  throws ParameterException
Parameterizable Interface - Configuration

Specified by:
parameterize in interface Parameterizable
Throws:
ParameterException

setup

public void setup(Parameters params)
Setup this component

Specified by:
setup in interface org.apache.cocoon.components.pipeline.ProcessingPipeline

informBranchPoint

public void informBranchPoint()
Informs pipeline we have come across a branch point. Default behaviour is do nothing.

Specified by:
informBranchPoint in interface org.apache.cocoon.components.pipeline.ProcessingPipeline

getGenerator

public org.apache.cocoon.generation.Generator getGenerator()
Get the generator - used for content aggregation

Specified by:
getGenerator in interface org.apache.cocoon.components.pipeline.ProcessingPipeline

setGenerator

public void setGenerator(String role,
                         String source,
                         Parameters param,
                         Parameters hintParam)
                  throws org.apache.cocoon.ProcessingException
Set the generator that will be used as the initial step in the pipeline. The generator role is given : the actual Generator is fetched from the latest ServiceManager.

Specified by:
setGenerator in interface org.apache.cocoon.components.pipeline.ProcessingPipeline
Parameters:
role - the generator role in the component manager.
source - the source where to produce XML from, or null if no source is given.
param - the parameters for the generator.
Throws:
org.apache.cocoon.ProcessingException - if the generator couldn't be obtained.

addTransformer

public void addTransformer(String role,
                           String source,
                           Parameters param,
                           Parameters hintParam)
                    throws org.apache.cocoon.ProcessingException
Add a transformer at the end of the pipeline. The transformer role is given : the actual Transformer is fetched from the latest ServiceManager.

Specified by:
addTransformer in interface org.apache.cocoon.components.pipeline.ProcessingPipeline
Parameters:
role - the transformer role in the component manager.
source - the source used to setup the transformer (e.g. XSL file), or null if no source is given.
param - the parameters for the transfomer.
Throws:
org.apache.cocoon.ProcessingException - if the generator couldn't be obtained.

setSerializer

public void setSerializer(String role,
                          String source,
                          Parameters param,
                          Parameters hintParam,
                          String mimeType)
                   throws org.apache.cocoon.ProcessingException
Set the serializer for this pipeline

Specified by:
setSerializer in interface org.apache.cocoon.components.pipeline.ProcessingPipeline
Parameters:
mimeType - Can be null
Throws:
org.apache.cocoon.ProcessingException

setReader

public void setReader(String role,
                      String source,
                      Parameters param,
                      String mimeType)
               throws org.apache.cocoon.ProcessingException
Set the reader for this pipeline

Specified by:
setReader in interface org.apache.cocoon.components.pipeline.ProcessingPipeline
Parameters:
mimeType - Can be null
Throws:
org.apache.cocoon.ProcessingException

setErrorHandler

public void setErrorHandler(org.apache.cocoon.sitemap.SitemapErrorHandler errorHandler)
Sets error handler for this pipeline. Used for handling errors in the internal pipelines.

Specified by:
setErrorHandler in interface org.apache.cocoon.components.pipeline.ProcessingPipeline
Parameters:
errorHandler - error handler

checkPipeline

protected boolean checkPipeline()
Sanity check

Returns:
true if the pipeline is 'sane', false otherwise.

setupPipeline

protected void setupPipeline(org.apache.cocoon.environment.Environment environment)
                      throws org.apache.cocoon.ProcessingException
Setup pipeline components.

Throws:
org.apache.cocoon.ProcessingException

connect

protected void connect(org.apache.cocoon.environment.Environment environment,
                       org.apache.cocoon.xml.XMLProducer producer,
                       org.apache.cocoon.xml.XMLConsumer consumer)
                throws org.apache.cocoon.ProcessingException
Connect the next component

Throws:
org.apache.cocoon.ProcessingException

connectPipeline

protected void connectPipeline(org.apache.cocoon.environment.Environment environment)
                        throws org.apache.cocoon.ProcessingException
Connect the XML pipeline.

Throws:
org.apache.cocoon.ProcessingException

process

public boolean process(org.apache.cocoon.environment.Environment environment)
                throws org.apache.cocoon.ProcessingException
Process the given Environment, producing the output.

Specified by:
process in interface org.apache.cocoon.components.pipeline.ProcessingPipeline
Throws:
org.apache.cocoon.ProcessingException

preparePipeline

protected void preparePipeline(org.apache.cocoon.environment.Environment environment)
                        throws org.apache.cocoon.ProcessingException
Prepare the pipeline

Throws:
org.apache.cocoon.ProcessingException

prepareInternal

public void prepareInternal(org.apache.cocoon.environment.Environment environment)
                     throws org.apache.cocoon.ProcessingException
Prepare an internal processing.

Specified by:
prepareInternal in interface org.apache.cocoon.components.pipeline.ProcessingPipeline
Parameters:
environment - The current environment.
Throws:
org.apache.cocoon.ProcessingException

prepareInternalErrorHandler

protected void prepareInternalErrorHandler(org.apache.cocoon.environment.Environment environment,
                                           org.apache.cocoon.ProcessingException ex)
                                    throws org.apache.cocoon.ProcessingException
If prepareInternal fails, prepare internal error handler.

Throws:
org.apache.cocoon.ProcessingException

isInternalError

protected boolean isInternalError()
Returns:
true if error happened during internal pipeline prepare call.

processXMLPipeline

protected boolean processXMLPipeline(org.apache.cocoon.environment.Environment environment)
                              throws org.apache.cocoon.ProcessingException
Process the SAX event pipeline

Throws:
org.apache.cocoon.ProcessingException

setupReader

protected void setupReader(org.apache.cocoon.environment.Environment environment)
                    throws org.apache.cocoon.ProcessingException
Setup the reader

Throws:
org.apache.cocoon.ProcessingException

setMimeTypeForReader

protected void setMimeTypeForReader(org.apache.cocoon.environment.Environment environment)
Set the mime-type for a reader

Parameters:
environment - The current environment

setMimeTypeForSerializer

protected void setMimeTypeForSerializer(org.apache.cocoon.environment.Environment environment)
                                 throws org.apache.cocoon.ProcessingException
Set the mime-type for a serializer

Parameters:
environment - The current environment
Throws:
org.apache.cocoon.ProcessingException

checkIfModified

protected boolean checkIfModified(org.apache.cocoon.environment.Environment environment,
                                  long lastModified)
                           throws org.apache.cocoon.ProcessingException
Throws:
org.apache.cocoon.ProcessingException

processReader

protected boolean processReader(org.apache.cocoon.environment.Environment environment)
                         throws org.apache.cocoon.ProcessingException
Process the pipeline using a reader.

Throws:
org.apache.cocoon.ProcessingException - if

recycle

public void recycle()
Specified by:
recycle in interface Recyclable
See Also:
Recyclable.recycle()

process

public boolean process(org.apache.cocoon.environment.Environment environment,
                       org.apache.cocoon.xml.XMLConsumer consumer)
                throws org.apache.cocoon.ProcessingException
Process the given Environment, but do not use the serializer. Instead all SAX events are streamed to the XMLConsumer.

Specified by:
process in interface org.apache.cocoon.components.pipeline.ProcessingPipeline
Throws:
org.apache.cocoon.ProcessingException

processErrorHandler

protected boolean processErrorHandler(org.apache.cocoon.environment.Environment environment,
                                      org.apache.cocoon.ProcessingException e,
                                      org.apache.cocoon.xml.XMLConsumer consumer)
                               throws org.apache.cocoon.ProcessingException
Throws:
org.apache.cocoon.ProcessingException

getValidityForEventPipeline

public SourceValidity getValidityForEventPipeline()
Return valid validity objects for the event pipeline If the "event pipeline" (= the complete pipeline without the serializer) is cacheable and valid, return all validity objects. Otherwise return null

Specified by:
getValidityForEventPipeline in interface org.apache.cocoon.components.pipeline.ProcessingPipeline

getKeyForEventPipeline

public String getKeyForEventPipeline()
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 null

Specified by:
getKeyForEventPipeline in interface org.apache.cocoon.components.pipeline.ProcessingPipeline

getLocation

protected org.apache.cocoon.util.location.Location getLocation(Parameters param)

handleException

protected void handleException(Exception e)
                        throws org.apache.cocoon.ProcessingException
Handles exception which can happen during pipeline processing. If this not a connection reset, then all locations for pipeline components are added to the exception.

Throws:
org.apache.cocoon.ConnectionResetException - if connection reset detected
org.apache.cocoon.ProcessingException - in all other cases


Copyright © 1999-2008 The Apache Software Foundation. All Rights Reserved.