You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by mike shugar <Mi...@hotmail.com> on 2012/09/25 04:53:04 UTC

[SCXML] - Events, Payload, DataModel - seeking simple working example

Hi SCXML users, this is my first post.

I have been learning commons SCXML over the last month or so, and have made
good progress with my own modified AbstractStateMachine, but I am now stuck.

I am trying to develop a stand alone Java application that uses SCXML for
state orchestration, and external classes to perform steps.

The pattern I want is to have:
1. SCXML transitions into a state,
2. SCXML calls out to an external class (OnEntry) to perform a step, passing
DataModel Data as input to the external class
3. the external class asynchronously performs the step based on the passed
Data,
4. the external class modifies the passed Data based on the performance of
the step
5. the external class passes an event (TriggerEvents) to SCXML with updated
Data to be made available in the State Machine for future steps.

I am successful up to step 4. But I have been unable to get the updated Data
to be absorbed into the AbstractStateMachine. I am working stand alone and
would like to avoid JEXL and EL.

Can anyone provide a working example of DataModel Data being updated in a
TriggerEvent?

I have tried to TriggerEvent with a payload, but could not figure out how to
make that payload stick to a state's Datamodel. This is my preferred way of
passing Data into the Statemachine if I can get it working, but I want to
avoid JEXL/EL.

I also tried the following code to force an update to the DataModel.  It
does not throw an exception, but the Data Model is not updated.


private void updateInfo() {
 String str = "";
 Map children =
MyAbstractStateMachine.getEngine().getStateMachine().getTargets();
 State state = ((State) children.get("myStateWithADataModel"));
    Datamodel dm = state.getDatamodel();

 Data newData = new Data();
 myXMLNode.getFirstChild().setTextContent("Did I succeed in changing
Datamodel by XML Node content?  Sorry no.");
 newData.setNode(myXMLNode);
 newData.setId("AddedTag");
 dm.addData(newData);
}



Thanks in advance for any help or examples.

Mike



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