3.org/TR/2014/CR-scxml-20140313/#AlgorithmforSCXMLInterpretation"> W3C SCXML Algorithm for SCXML Interpretation from the
SCXMLExecutor
and therefore make it pluggable.
From an SCXML execution POV, there are only three entry points needed into the Algorithm, namely:
- Performing the initialization of the state machine and completing a first macro step, see: {@link #firstStep(SCXMLExecutionContext)}. The state machine thereafter should be ready for processing external events (or be terminated already)
- Processing a single external event and completing the macro step for it, after which the state machine should be ready for processing another external event (if any), or be terminated already. See: {@link #nextStep(SCXMLExecutionContext,TriggerEvent)}.
- Finally, if the state machine terminated ( {@link SCXMLExecutionContext#isRunning()} == false), after eitherof the above steps, finalize the state machine by performing the final step. See: {@link #finalStep(SCXMLExecutionContext)}.
After a state machine has been terminated you can re-initialize the execution context, and start again.
Except for the loading of the SCXML document and (re)initializing the {@link SCXMLExecutionContext}, the above steps represent the interpret,mainEventLoop and exitInterpreter entry points specified in Algorithm for SCXML Interpretation, but more practically and logically broken into separate steps so that the blocking wait for external events can be handled externally.
These three entry points are the only interface methods used by the SCXMLExecutor. It is up to the specific SCXMLSemantics implementation to provide the concrete handling for these according to the Algorithm in the SCXML specification (or possibly something else/different).
The default {@link org.apache.commons.scxml2.semantics.SCXMLSemanticsImpl} provides an implementation of thespecification, and can easily be overridden/customized as a whole or only on specific parts of the Algorithm implementation.
Note that both the {@link #firstStep(SCXMLExecutionContext)} and {@link #nextStep(SCXMLExecutionContext,TriggerEvent)}first run to completion for any internal events raised before returning, as expected and required by the SCXML specification, so it is currently not possible to 'manage' internal event processing externally.
Specific semantics can be created by subclassing org.apache.commons.scxml2.semantics.SCXMLSemanticsImpl
.