org.apache.commons.pipeline.stage
Class BaseStage

java.lang.Object
  extended by org.apache.commons.pipeline.stage.BaseStage
All Implemented Interfaces:
Stage
Direct Known Subclasses:
AddToCollectionStage, DynamicLookupStaticMethodStage, FileFinderStage, FtpFileDownloadStage, HttpFileDownloadStage, InputStreamLineBreakStage, InvokeMethodStage, InvokeStaticMethodStage, KeyWaitBufferStage, LogStage, PipelineShutdownStage, RaiseEventStage, RaiseKeyAvailableEventStage, URLToInputStreamStage

public abstract class BaseStage
extends Object
implements Stage

This is a simple base class for Stages with no-op implementations of the preprocess(), #process(), postprocess(), and release() methods.


Field Summary
protected  StageContext context
          The context in which the stage runs.
 
Constructor Summary
BaseStage()
           
 
Method Summary
 void emit(Object obj)
          Convenience method to feed the specified object to the next stage downstream.
 void emit(String branch, Object obj)
          Convenience method to feed the specified object to the first stage of the specified branch.
 void init(StageContext context)
          This implementation of init() simply stores a reference to the stage context.
 void postprocess()
          No-op implementation.
 void preprocess()
          No-op implementation.
 void process(Object obj)
          The only operation performed by this implementation of process() is to feed the specified object to the downstream feeder.
 void release()
          No-op implementation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

context

protected StageContext context
The context in which the stage runs.

Constructor Detail

BaseStage

public BaseStage()
Method Detail

init

public void init(StageContext context)
This implementation of init() simply stores a reference to the stage context.

Specified by:
init in interface Stage
Parameters:
context - the StageContext within which the stage sill be run

preprocess

public void preprocess()
                throws StageException
No-op implementation. This method should be overridden to provide preprocessing capability for the stage.

Specified by:
preprocess in interface Stage
Throws:
StageException - an Exception thrown by an overriding implementation should be wrapped in a StageException
See Also:
Stage.preprocess()

process

public void process(Object obj)
             throws StageException
The only operation performed by this implementation of process() is to feed the specified object to the downstream feeder. This method should be overridden to provide processing capability for the stage.

Specified by:
process in interface Stage
Parameters:
obj - Object to be passed to downstream pipeline.
Throws:
StageException - an Exception thrown by an overriding implementation should be wrapped in a StageException

postprocess

public void postprocess()
                 throws StageException
No-op implementation. This method should be overridden to provide postprocessing capability for the stage.

Specified by:
postprocess in interface Stage
Throws:
StageException - an Exception thrown by an overriding implementation should be wrapped in a StageException

release

public void release()
No-op implementation. This method should be overridden to provide resource release capability for the stage. Implementations overriding this method should clean up any lingering resources that might otherwise be left allocated if an exception is thrown during processing.

Specified by:
release in interface Stage
See Also:
Stage.release()

emit

public final void emit(Object obj)
Convenience method to feed the specified object to the next stage downstream.


emit

public final void emit(String branch,
                       Object obj)
Convenience method to feed the specified object to the first stage of the specified branch.



Copyright © 2004-2009 The Apache Software Foundation. All Rights Reserved.