The Invoker interface is used to define the possible interactions between the parent state machine (executor) and the types of invocable activities.
Invocable activities must first register an Invoker implementation class for the appropriate "target" (attribute of <invoke>) with the parent SCXMLParentIOProcessor
.
The communication link between the parent state machine executor and the invoked activity is a asynchronous bi-directional events pipe.
All events triggered on the parent state machine get forwarded to the invoked activity. The processing semantics for these events depend upon the "target", and thereby vary per concrete implementation of this interface.
The invoked activity in turn must fire a special "done" event when it concludes. It may fire additional events before the "done" event. The semantics of any additional events depend upon the "target". The invoked activity must not fire any events after the "done" event. The name of the special "done" event must be "done.invoke.id" with the ID of the parent state wherein the corresponding <invoke> resides,
The Invoker "lifecycle" is outlined below:
- Instantiation via {@link Class#newInstance()}(Invoker implementation requires accessible constructor).
- Configuration (setters for invoke ID and {@link org.apache.commons.scxml2.SCXMLIOProcessor}).
- Initiation of invoked activity via invoke() method, passing the source URI and the map of params.
- Zero or more bi-directional event triggering.
- Either completion or cancellation.
Note: The semantics of <invoke> are necessarily asynchronous, tending towards long(er) running interactions with external processes. Implementations cannot communicate with the parent state machine executor in a synchronous manner. For synchronous communication semantics, use <event> or custom actions instead.