Step APIs
One of the goals of JAFPL is to conceal as much of the underlying framework as possible from step implementors. Atomic steps are only required to implement an API; almost nothing about the framework is exposed. (Containers are a little trickier; there aren’t any provisions for extension containers at the moment, but I’m open to suggestions for new containers.)
The API for atomic steps is straightforward. Each step implmentation must implement the Step interface.
Most of the interface is completely straightforward:
initialize(runtime)
will be called once as pipeline execution begins. The current runtime configuration is passed in.receive(port,item)
will be called once for each input the step receives on the port. If the step receives no inputs, this method will not be called.receiveBinding(variable,value)
will be called once for each variable binding provided to the step. If no bindings apply, this method will not be called.run()
will be called once to run the step.reset()
will called once between each iteration if the step appears in a loop.abort()
will be called if execution fails for the container in which the step appears. This must be treated as a variation ofreset()
. If the failure is caught by a try/catch, and the try/catch is in a loop, the step may run again.stop()
will be called once as pipeline execution ends.
That leaves only a few odds and ends.
The
inputSpec()
,outputSpec()
, andbindingSpec()
methods will be called once. They allow the step to enumerate what inputs and outputs it has (and their cardinalities) as well as the bindings that it requires. This allows the pipeline engine to detect pipelines that have been constructed incorrectly.setConsumer(consumer)
will be called once, before execution begins. This provides the step with a way to produce results. When the running step wishes to send output to the pipeline, it callsreceive(port,item)
on the consumer.setLocation(location)
may also be called once. It provides information about the location of the step. This could be used, for example, in an implementation that provides a declarative grammar for constructing pipelines. Steps aren’t required to do anything with the location, but it may be useful in error messages, for example.