commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rahul Akolkar <rahul.akol...@gmail.com>
Subject Re: [scxml] stop and resume by serializing the executor does not work
Date Fri, 02 Jul 2010 20:41:31 GMT
On Thu, Jul 1, 2010 at 8:56 PM, RT <aarathi@gmail.com> wrote:
>
> My scxml is defined like this:
>                       <state id="stateA">
>                                <onentry>
>                                        <log expr="'Inside stateA'"/>
>                                </onentry>
>                                <onexit>
>                                        <log expr="'Leaving stateA'"/>
>                                </onexit>
>                                <transition event="gotoB" target="stateB"/>
>                        </state>
>                        <final id="stateB">
>                                <onentry>
>                                        <log expr="'Inside stateB'"/>
>                                </onentry>
>                                <onexit>
>                                        <log expr="'Leaving stateB'"/>
>                                </onexit>
>                        </final>
>
> So, I initiate an SCXMLExecutor object, set all the requisites and call go()
> , like this:
>
> SCXMLExecutor engine = new SCXMLExecutor(getEvaluator(), new
> SimpleDispatcher(),
>                                new SimpleErrorReporter());
>                engine.setStateMachine(getSCXML());
>                engine.setSuperStep(true);
>                engine.setRootContext(getContext());
>                engine.addListener(getSCXML(), getListener());
>                try {
>                        engine.go();
>                } catch (ModelException me) {
>                        me.printStackTrace();
>                }
>
> In the listener, I override the onEntry like this:
>
> public void onEntry(TransitionTarget state) {
>                System.out.println("Entering state " + state.getId());
>        }
>
> After I call go() on my executor, I see the stateA being entered and then
> the state machine stops as its waiting for the "gotoB" event to transition
> to the next state.
>
> Now, I serialize this executor object to a file.Wait for a few seconds, then
> deserialize it and then call fireEvent("gotoB") which is defined as:
>
> public void fireEvent(String eventName) {
>                try {
>                        executor.triggerEvent(new TriggerEvent(eventName,
>                                        TriggerEvent.SIGNAL_EVENT));
>                        System.out.println("fired eventsuccessfully:"+eventName);
>                } catch (ModelException e) {
>                        e.printStackTrace();
>                }
>        }
>
> I see in the log that my event was fired on the executor, but I do not see
> the stateB being entered.
<snip/>

To confirm, rather than rely on any listener output, introspect the
executor directly. So, after the System.out.println line above, check
the active state(s) via executor.getCurrentStatus().getStates() -- one
would expect "stateB" as the ID of the active state in this case.


> So obviously during serialization/deserialization
> some entities were lost on the executor object. Any idea what I should be
> looking for?
>
<snap/>

We do serialization round trips and have tests for it as well.
Assumption is that all application provided listeners, data,
dispatchers, invokers etc. are serializable (check that is the case
here). Another thing to do would be to create a unit test for the
Commons SCXML test suite that demonstrates what you are observing and
then we can look at it.

-Rahul

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message