org.apache.cocoon.components.pipeline
Class AbstractProcessingPipeline

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.components.pipeline.AbstractProcessingPipeline
All Implemented Interfaces:
Poolable, Recyclable, Component, Composable, Recomposable, LogEnabled, Parameterizable, ProcessingPipeline
Direct Known Subclasses:
BaseCachingProcessingPipeline, NonCachingProcessingPipeline

public abstract class AbstractProcessingPipeline
extends AbstractLogEnabled
implements ProcessingPipeline, Parameterizable, Recyclable

This is the base for all implementations of a ProcessingPipeline.

Since:
2.1
Version:
CVS $Id: AbstractProcessingPipeline.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Carsten Ziegeler

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  Generator generator
           
protected  Parameters generatorParam
           
protected  ComponentSelector generatorSelector
           
protected  String generatorSource
           
protected  XMLConsumer lastConsumer
          This is the last component in the pipeline, either the serializer or a custom XML consumer in case of internal processing.
protected  ComponentManager manager
          The component manager set with compose()
protected  ComponentManager newManager
          The component manager set with compose() and recompose()
protected  int outputBufferSize
          Output Buffer Size
protected  Parameters parameters
          The parameters
protected  Reader reader
           
protected  String readerMimeType
           
protected  Parameters readerParam
           
protected  OutputComponentSelector readerSelector
           
protected  String readerSource
           
protected  Serializer serializer
           
protected  String serializerMimeType
           
protected  Parameters serializerParam
           
protected  OutputComponentSelector serializerSelector
           
protected  String serializerSource
           
protected  String sitemapReaderMimeType
           
protected  String sitemapSerializerMimeType
           
protected  ArrayList transformerParams
           
protected  ArrayList transformers
           
protected  ArrayList transformerSelectors
           
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(Environment environment, long lastModified)
           
protected  boolean checkPipeline()
          Sanity check
 void compose(ComponentManager manager)
          Composable Interface
protected  void connect(Environment environment, XMLProducer producer, XMLConsumer consumer)
          Connect the next component
protected  void connectPipeline(Environment environment)
          Connect the XML pipeline.
 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  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(Environment environment)
          Prepare an internal processing.
protected  void prepareInternalErrorHandler(Environment environment, ProcessingException ex)
          If prepareInternal fails, prepare internal error handler.
protected  void preparePipeline(Environment environment)
          Prepare the pipeline
 boolean process(Environment environment)
          Process the given Environment, producing the output.
 boolean process(Environment environment, XMLConsumer consumer)
          Process the given Environment, but do not use the serializer.
protected  boolean processErrorHandler(Environment environment, ProcessingException e, XMLConsumer consumer)
           
protected  boolean processReader(Environment environment)
          Process the pipeline using a reader.
protected  boolean processXMLPipeline(Environment environment)
          Process the SAX event pipeline
 void recompose(ComponentManager manager)
          Recomposable Interface
 void recycle()
           
 void release()
          Release this component.
 void setErrorHandler(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(Environment environment)
          Set the mime-type for a reader
protected  void setMimeTypeForSerializer(Environment environment)
          Set the mime-type for a serializer
 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(Environment environment)
          Setup pipeline components.
protected  void setupReader(Environment environment)
          Setup the reader
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

generator

protected Generator generator

generatorParam

protected Parameters generatorParam

generatorSource

protected String generatorSource

generatorSelector

protected ComponentSelector generatorSelector

transformers

protected ArrayList transformers

transformerParams

protected ArrayList transformerParams

transformerSources

protected ArrayList transformerSources

transformerSelectors

protected ArrayList transformerSelectors

serializer

protected Serializer serializer

serializerParam

protected Parameters serializerParam

serializerSource

protected String serializerSource

serializerMimeType

protected String serializerMimeType

sitemapSerializerMimeType

protected String sitemapSerializerMimeType

serializerSelector

protected OutputComponentSelector serializerSelector

reader

protected Reader reader

readerParam

protected Parameters readerParam

readerSource

protected String readerSource

readerMimeType

protected String readerMimeType

sitemapReaderMimeType

protected String sitemapReaderMimeType

readerSelector

protected OutputComponentSelector readerSelector

lastConsumer

protected 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 ComponentManager manager
The component manager set with compose()


newManager

protected ComponentManager 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

Constructor Detail

AbstractProcessingPipeline

public AbstractProcessingPipeline()
Method Detail

compose

public void compose(ComponentManager manager)
             throws ComponentException
Composable Interface

Specified by:
compose in interface Composable
Throws:
ComponentException

recompose

public void recompose(ComponentManager manager)
               throws ComponentException
Recomposable Interface

Specified by:
recompose in interface Recomposable
Throws:
ComponentException

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 ProcessingPipeline

release

public void release()
Release this component. If you get an instance not by a component manager but for example by a processor, you have to release this component by calling this method and NOT by using a component manager!

Specified by:
release in interface ProcessingPipeline

informBranchPoint

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

Specified by:
informBranchPoint in interface ProcessingPipeline

getGenerator

public Generator getGenerator()
Get the generator - used for content aggregation

Specified by:
getGenerator in interface ProcessingPipeline

setGenerator

public void setGenerator(String role,
                         String source,
                         Parameters param,
                         Parameters hintParam)
                  throws 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 ComponentManager given by compose() or recompose().

Specified by:
setGenerator in interface 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:
ProcessingException - if the generator couldn't be obtained.

addTransformer

public void addTransformer(String role,
                           String source,
                           Parameters param,
                           Parameters hintParam)
                    throws ProcessingException
Add a transformer at the end of the pipeline. The transformer role is given : the actual Transformer is fetched from the latest ComponentManager given by compose() or recompose().

Specified by:
addTransformer in interface 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:
ProcessingException - if the generator couldn't be obtained.

setSerializer

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

Specified by:
setSerializer in interface ProcessingPipeline
Parameters:
mimeType - Can be null
Throws:
ProcessingException

setReader

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

Specified by:
setReader in interface ProcessingPipeline
Parameters:
mimeType - Can be null
Throws:
ProcessingException

setErrorHandler

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

Specified by:
setErrorHandler in interface ProcessingPipeline
Parameters:
errorHandler - error handler

checkPipeline

protected boolean checkPipeline()
Sanity check

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

setupPipeline

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

Throws:
ProcessingException

connect

protected void connect(Environment environment,
                       XMLProducer producer,
                       XMLConsumer consumer)
                throws ProcessingException
Connect the next component

Throws:
ProcessingException

connectPipeline

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

Throws:
ProcessingException

process

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

Specified by:
process in interface ProcessingPipeline
Throws:
ProcessingException

preparePipeline

protected void preparePipeline(Environment environment)
                        throws ProcessingException
Prepare the pipeline

Throws:
ProcessingException

prepareInternal

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

Specified by:
prepareInternal in interface ProcessingPipeline
Parameters:
environment - The current environment.
Throws:
ProcessingException

prepareInternalErrorHandler

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

Throws:
ProcessingException

isInternalError

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

processXMLPipeline

protected boolean processXMLPipeline(Environment environment)
                              throws ProcessingException
Process the SAX event pipeline

Throws:
ProcessingException

setupReader

protected void setupReader(Environment environment)
                    throws ProcessingException
Setup the reader

Throws:
ProcessingException

setMimeTypeForReader

protected void setMimeTypeForReader(Environment environment)
                             throws ProcessingException
Set the mime-type for a reader

Parameters:
environment - The current environment
Throws:
ProcessingException

setMimeTypeForSerializer

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

Parameters:
environment - The current environment
Throws:
ProcessingException

checkIfModified

protected boolean checkIfModified(Environment environment,
                                  long lastModified)
                           throws ProcessingException
Throws:
ProcessingException

processReader

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

Throws:
ProcessingException - if

recycle

public void recycle()
Specified by:
recycle in interface Recyclable

process

public boolean process(Environment environment,
                       XMLConsumer consumer)
                throws 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 ProcessingPipeline
Throws:
ProcessingException

processErrorHandler

protected boolean processErrorHandler(Environment environment,
                                      ProcessingException e,
                                      XMLConsumer consumer)
                               throws ProcessingException
Throws:
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 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 ProcessingPipeline

getLocation

protected Location getLocation(Parameters param)

handleException

protected void handleException(Exception e)
                        throws 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:
ConnectionResetException - if connection reset detected
ProcessingException - in all other cases


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