commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dario D <darac1...@gmail.com>
Subject [scxml] Calling go() twice
Date Tue, 03 May 2011 12:17:56 GMT
Hello all,

I've just started using SCXML and it's great. However, I've hit a brick wall
and I can't seem to figure out something. I have the following XML file:

<scxml xmlns="http://www.w3.org/2005/07/scxml"
       version="1.0"
       initialstate="state1">

    <state id="state1">
        <onentry>
            <log expr="State 1"/>
        </onentry>
        <transition target="state2" />
    </state>

    <state id="state2">
        <onentry>
            <log expr="State 2"/>
        </onentry>
        <transition target="state3" cond="1 = 2" />
    </state>

    <state id="state3" final="true">
        <onentry>
            <log expr="State 3"/>
        </onentry>
    </state>

</scxml>

Now, I execute the state machine like this:

        SCXMLExecutor exec = null;
        exec = new SCXMLExecutor(new ELEvaluator(), new SimpleDispatcher(),
new SimpleErrorReporter());
        Context ctx = new ELContext();
        exec.setRootContext(ctx);
        exec.setStateMachine(scxml);
        exec.setSuperStep(true);
        // Start execution
        try {
            exec.go();
            exec.go();
        } catch (ModelException e) {
            e.printStackTrace();
        }

As you can see I call exec.go() two times. I would expect that in the first
time, the state machine will stop in the "state2" state and remain there,
because condition is not satisfied for going into "state3". However, when
exec.go() is called the second time, it goes from the start. Effectively, it
acts as exec.reset()? Following output is provided:

        03.05.2011. 14:01:32 org.apache.commons.scxml.model.Log execute
        INFO: null: State 1
        03.05.2011. 14:01:32 org.apache.commons.scxml.model.Log execute
        INFO: null: State 2
        03.05.2011. 14:01:32 org.apache.commons.scxml.model.Log execute
        INFO: null: State 1
        03.05.2011. 14:01:32 org.apache.commons.scxml.model.Log execute
        INFO: null: State 2

Could you explain this behavior?

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