Hi all,
I would like to know the best practice to serialize/deserialize SCXML fsm.
I do this during the creation of the SCXML executor, scInstace is the
serialized context:
List<CustomAction> customActions = new ArrayList<CustomAction>();
CustomAction ca =
new CustomAction("http://my.custom-actions.domain/CUSTOM1",
"hello", Hello.class);
customActions.add(ca);
JexlEvaluator evaluator = new JexlEvaluator();
try {
scxml = SCXMLReader.read(StopWatch.class.getClassLoader().
} catch (Exception e) {
e.printStackTrace();
throw e;
}
executor = null;
try {
executor = new SCXMLExecutor(evaluator, null, new
SimpleErrorReporter());
if (scInstance != null) {
// serialized context use it
executor.attachInstance(scInstance);
executor.registerInvokerClass("x-test", DummyInvoker.class);
executor.setStateMachine(scxml);
executor.go();
setInitialState(executor, "paused");
} else {
// new context
Context rootContext = new JexlContext();
rootContext.set("var1", "value1");
executor.registerInvokerClass("x-test", DummyInvoker.class);
executor.setStateMachine(scxml);
executor.setRootContext(rootContext);
executor.go();
}
} catch (ModelException me) {
// Executor initialization failed, because the
// state machine specified has inconsistencies
me.printStackTrace();
}
I serialize executor.detachInstance(). It's seem to work, but is it the right
way to restart a SCXML 'session' ?
Thanks
Francis.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]