org.apache.commons.pipeline.testFramework
Class TestStageContext

java.lang.Object
  extended by org.apache.commons.pipeline.testFramework.TestStageContext
All Implemented Interfaces:
StageContext

public class TestStageContext
extends Object
implements StageContext

Stage Context for test harness.


Field Summary
 Map<String,TestFeeder> branchFeeders
           
 Map<Stage,Feeder> downstreamFeeders
           
 Map<String,Object> env
           
 List<StageEventListener> listeners
           
 List<EventObject> raisedEvents
           
 
Constructor Summary
TestStageContext()
           
 
Method Summary
 Feeder getBranchFeeder(String key)
          Dynamically adds branch feeders as needed to provide a feeder for the requested branch key.
 Feeder getDownstreamFeeder(Stage stage)
          Dynamically adds downstream feeders as needed to provide a downstream feeder for the specified stage.
 Object getEnv(String key)
          This method allows objects in the global environment to be accessed by the stages running in this context.
 Collection<StageEventListener> getRegisteredListeners()
          Returns the collection of StageEventListeners registered with the context.
 void raise(EventObject ev)
          Notifies each registered listener of an event and propagates the event to any attached branches
 void registerDownstreamFeeder(Stage stage, Feeder feeder)
          This method is used by the test implementation to set up the feeders for a stage as though they were provided by drivers in a pipeline.
 void registerListener(StageEventListener listener)
          Adds a StageEventListener to the context that will be notified by calls to StageContext.raise(EventObject).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listeners

public List<StageEventListener> listeners

raisedEvents

public List<EventObject> raisedEvents

branchFeeders

public Map<String,TestFeeder> branchFeeders

downstreamFeeders

public Map<Stage,Feeder> downstreamFeeders

env

public Map<String,Object> env
Constructor Detail

TestStageContext

public TestStageContext()
Method Detail

registerListener

public void registerListener(StageEventListener listener)
Description copied from interface: StageContext
Adds a StageEventListener to the context that will be notified by calls to StageContext.raise(EventObject).

Specified by:
registerListener in interface StageContext
Parameters:
listener - The listener to be registered with the context.

raise

public void raise(EventObject ev)
Description copied from interface: StageContext
Notifies each registered listener of an event and propagates the event to any attached branches

Specified by:
raise in interface StageContext
Parameters:
ev - The event to be passed to registered listeners

getBranchFeeder

public Feeder getBranchFeeder(String key)
Dynamically adds branch feeders as needed to provide a feeder for the requested branch key.

Specified by:
getBranchFeeder in interface StageContext
Parameters:
key - the string identifer of the branch for which a feeder will be retrieved
Returns:
the Feeder for the first stage of the specified branch

getDownstreamFeeder

public Feeder getDownstreamFeeder(Stage stage)
Dynamically adds downstream feeders as needed to provide a downstream feeder for the specified stage.

Specified by:
getDownstreamFeeder in interface StageContext
Parameters:
stage - The stage from which "downstream" will be determined. Ordinarily a Stage implementation will call this method with a reference to itself.
Returns:
the feeder for the downstream stage, or Feeder.VOID if no downstream stage exists.

registerDownstreamFeeder

public void registerDownstreamFeeder(Stage stage,
                                     Feeder feeder)
This method is used by the test implementation to set up the feeders for a stage as though they were provided by drivers in a pipeline.


getRegisteredListeners

public Collection<StageEventListener> getRegisteredListeners()
Description copied from interface: StageContext
Returns the collection of StageEventListeners registered with the context.

Specified by:
getRegisteredListeners in interface StageContext
Returns:
the collection of StageEventListeners registered with the context.

getEnv

public Object getEnv(String key)
This method allows objects in the global environment to be accessed by the stages running in this context.

Specified by:
getEnv in interface StageContext
Returns:
the object corresponding to the specified string key, or null if no such key exists.


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