commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Armel SORO <armel.soro.sc...@gmail.com>
Subject Re: [SCXML] Parent and child engines
Date Mon, 09 Mar 2009 13:44:50 GMT
Thank you for this input, Rahul!
It sounds clear now!
However, is it normal that, after having defined my own Invoker
Implementation (by implementing the Invoker JAVA interface as you said), the
cancel() method be called instead of the parentEvents() one when I try to
trigger the special done event "externalActivity.invoke.done" to the derived
engine?

Regards,

--
Armel


2009/3/6 Rahul Akolkar <rahul.akolkar@gmail.com>

> On Fri, Mar 6, 2009 at 5:11 AM, Armel SORO <armel.soro.scxml@gmail.com>
> wrote:
> > Hi,
> >
> > Since I am new to SCXML, I have some questions to ask:
> > First, is it possible to automatically trigger an event from a derived
> > engine to a main engine?
> <snip/>
>
> In terms of current implementation, the only event that you can rely
> on is the $stateId.invoke.done event on completion of the 'child' as
> you use below (on the separate note, that event name is probably going
> to be changed in the next draft of the spec).
>
> There have been discussions about triggering events from invoked /
> child state machines to the parent (like you ask above), and I think
> the next draft will also draw out a mechanism to trigger an event on
> the parent using <send> syntax similar to:
>
>  <send target="_parent" type="scxml" name="foo.bar" ... />
>
> Once that is fleshed out in the spec, the Commons SCXML implementation
> will support it. Interim, you can define your own Invoker
> implementation to help with this (and use that instead of the
> SimpleSCXMLInvoker, which is the default).
>
>
> > Secondly, how can we handle "unexpected" events (events not taken into
> > account) in a given state machine?
> >
> <snap/>
>
> State machines don't really consider unexpected events to be any
> error, so these have to be coded by the author a bit defensively. For
> example, if such handling is necessary, this can be done by providing
> a composite parent state with a catch-all transition that is taken if
> none other are matched (this transition can handle the unexpected
> events using executable content as necessary for the use case).
>
> To illustrate, we can go from this which ignores unexpected events:
>
> <scxml initial="s1" ...>
>
>  <state id="s1">
>  ...
>  </state>
>
>  <state id="s2">
>  ...
>  </state>
>
>  ...
>
> </scxml>
>
> to this which provides the said catch-all transition:
>
> <scxml initial="s" ...>
>
>  <state id="s" initial="s1">
>
>    <transition event="*">
>      <!-- handle otherwise unexpected event -->
>    </transition>
>
>    <state id="s1">
>    ...
>    </state>
>
>    <state id="s2">
>    ...
>    </state>
>
>    ...
>
>  </state>
>
> </scxml>
>
>
> > Any answer to the questions above would be appreciated to deal with the
> > following case:
> > I have a main engine that is responsible for managing a given SCXML
> > document. A new engine is instantiated each time an external activity is
> > invoked in this document.
> > For example, the main SCXML document looks like this:
> >
> > <scxml ...>
> >   <state id="test1">
> >       <invoke src="SRC" targettype="scxml">
> >          <param name="param1" expr="'value1'"/>
> >       </invoke>
> >       <transition event="SRC.invoke.done" target="test2"/>
> >   </state>
> >   <state id="test2">
> >      ...
> >   </state>
> >   . ..
> > </scxml>
> >
> > So, invoking the external activity "SRC" causes the main engine to
> > instantiate and launch a derived engine that has the state machine below:
> >
> > <scxml ...>
> >  <state id="invokedActivity"/>
> >     <invoke src="WebSRC" targettype="web">
> >       <param name="textToDisplay" expr="param1"/>
> >    </invoke>
> >   <transition event="WebSRC.invoke.done" target="invocationDone"/>
> >  </state>
> >
> >  <final id="invocationDone">
> >   <event name="SRC.invoke.done"/>
> >  </finale>
> > ...
> > </scxml>
> >
> > What I want is that once this derived engine is triggered the event
> > "WebSRC.invoke.done", it raises the event "SRC.invoke.done" to the main
> > engine.
> <snip/>
>
> Makes sense, should be happening.
>
>
> > I also want the derived engine to forward "unexpected" events to its
> > parent engine.
> >
> <snap/>
>
> See above.
>
> -Rahul
>
>
> > Thanks in advance for ideas!
> >
> >
> > --
> > Armel SORO
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message