jconch.pipeline
Class PipeStage

java.lang.Object
  extended by jconch.pipeline.PipeStage
All Implemented Interfaces:
PipeElement
Direct Known Subclasses:
Consumer, Processor, Producer

public abstract class PipeStage
extends java.lang.Object
implements PipeElement

The base interface for a stage in the pipeline.

Author:
Robert Fischer

Constructor Summary
protected PipeStage(ThreadingModel threading)
          Constructor.
 
Method Summary
abstract  void execute()
          Executes one round of processing for this pipeline stage.
 ThreadingModel getThreadingModel()
          Gets the threading model of the instance.
abstract  boolean isFinished()
          If the pipeline is not supposed to handle any more elements, either because of an error or because a producer is exhausted.
 boolean isStarted()
          Whether this pipline stage has been started or not.
abstract  void logMessage(java.lang.String msg, java.lang.Exception e)
          Called when an exception occurs in execution.
 void start()
          Starts the pipeline within its threading model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PipeStage

protected PipeStage(ThreadingModel threading)
Constructor.

Parameters:
threading - The threading approach.
Throws:
org.apache.commons.lang.NullArgumentException - If the argument is null
Method Detail

start

public void start()
Starts the pipeline within its threading model. A pipline stage can only be started once; subsequent calls to this method do nothing.

Specified by:
start in interface PipeElement

isStarted

public boolean isStarted()
Whether this pipline stage has been started or not.

Returns:
If we have already started this pipeline stage.

execute

public abstract void execute()
Executes one round of processing for this pipeline stage.

Throws:
java.lang.IllegalStateException - If there is nothing left to execute.

isFinished

public abstract boolean isFinished()
If the pipeline is not supposed to handle any more elements, either because of an error or because a producer is exhausted.

Returns:
If the pipeline is done producing/consuming elements.

logMessage

public abstract void logMessage(java.lang.String msg,
                                java.lang.Exception e)
Called when an exception occurs in execution.

Parameters:
msg - The message describing the problem (may be null)
e - The exception which is the problem.

getThreadingModel

public ThreadingModel getThreadingModel()
Gets the threading model of the instance.

Returns:
the threading model