What Base Class Should I Extend?

When writing an own stage, you should know a few abstract classes that could save you some work.

  • Inherit from AbstractTransformation, if you want to write a stage that should have exactly one input port and exactly one output port, each with a different port type. You can access the input port by inputPort and the output port by outputPort.

  • Inherit from AbstractFilter, if you want to write a stage that should have exactly one input port and exactly one output port, both with the same port type. You can access the input port by inputPort and the output port by outputPort.

  • Inherit from AbstractConsumerStage, if you want to write a stage that should have exactly one input port and an arbitrary number of output ports. Example consumer stages are the CollectorSink and the InstanceOfFilter.

  • Inherit from AbstractStage, if you want to write a stage that should have more than one input port and an arbitrary number of output ports. An example stage is the Merger.

  • Inherit from AbstractProducerStage, if you want to write a stage that does not need to have any input ports. In this way, you get a stage with a pre-initialized producer semantics. Moreover, you can access a default output port named outputPort.
    Note: You need to place a workCompleted() call within your execute method to signal the framework when your producer stage has finished its job. Example producer stages are the InitialElementProducer and the Clock.

  • Inherit from CompositeStage, if you want to write a stage that is composed of several other stages. Such a stage does not have its own execute() method, but delays its input port(s) to its sub stage(s).

What Code Shall I Write?

You only need to implement the logics your stage should represent in the execute() method. If you need an input or an output port, declare it as instance field by using the createInputPort() and createOutputPort() methods. If your stage should have an internal state, follow these instructions.

The following examples will give you a short insight on how stages can be implemented:

Back to top

Reflow Maven skin by Andrius Velykis.