commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Schwager" <Daniel.Schwa...@dtnet.de>
Subject AW: [SCXML] Question save/restore state of FSM
Date Tue, 01 Jul 2008 06:40:12 GMT
> >  B) i would like to save/restore my FSM (using the SCXML in
> >  EJB3-container with session beans)
> >

> In order of preference:
> 
> 1) Persist the SCXMLExecutor instance below, instead of merely the
root context.
> 
> 2) Correctly set the states collection of the current executor status
> [ exec.getCurrentStatus().getStates() ] along with its root context
> 

Hi Rahul,

if i persist the SCXMLExecutor instance, I will also persist all the
injected codeeobjects like
	Evaluator
	ErrorReporter
	Eventdispatcher
	All Listeners

also. IMHO, it's better to choose your second way.

Now the code works:


			// init exec 
			....

			if (!sm.isInitialized()) {
				// First time - invoke Listener and
reset FSM
				exec.addListener(scxml, new
SimpleSCXMLListener());
				exec.addListener(scxml, new
StateMachineEntryListener(sm));
				sm.setInitialized(true);
				exec.go();

			} else {
				// reload the states
	
exec.getCurrentStatus().getStates().clear();
	
exec.getCurrentStatus().getStates().addAll(sm.getStates());

				exec.addListener(scxml, new
SimpleSCXMLListener());
				exec.addListener(scxml, new
StateMachineEntryListener(sm));
			}

			exec.triggerEvent(evt);

			// Save states
			sm.getStates().clear();
	
sm.getStates().addAll(exec.getCurrentStatus().getStates());

Thanks very much

Regards
Danny from softwaredemo.de (running SCXML inside ;)


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


Mime
View raw message