The current implementation of SimpleSCXMLInvoker assumes that only external
events, handled by parentEvents(), may cause the child state machine to
go move a final state. I had a case where the invoked state machine went to
a final state directly while executing the initial state, something like:

<scxml xmlns=http://www.w3.org/2005/07/scxml version="1.0"
initialstate="state1">
    <state id="state1">
         <onentry>
              <send event="foo"/>
         </onentry>

         <transition event="foo" target="state2" />
    </state>

    <state id="state2" final="true" />
</scxml>

Therefore the invoke got stucked and the parent never received an
invoke.done event.

I see two problems:

a) the parentEvents() method will not send a "invoke.done" event to the
parent because "doneBefore" will already be true (for the above example).
That means the parent gets never notified about the termination of the
child.

b) Even if we change the logic of parentEvents() in a way that a) will be
solved, the problem is still that the termination of the state machine will
only be detected once an external event occurs in the parent state machine
and thus the parentEvents() method will be called.

Is there a way to get notified in the environment of a state machine (like
the invoke-Implementation) once a state machine reaches the final state?
Until now I only found "polling" the current state like

if (executor.getCurrentStatus().isFinal()) { ..}

Don't we need a callback (implemented by an interface) to get notified about
reaching a final state? The child state machine (invoked from a parent state
machine) may communicate to another external process asynchronously and any
event from this external process may cause the child state machine to go to
a final state. How to notify the parent about termination of the invoke (i.e.
sending an invoke.done)?

- Ingmar.

Reply via email to