There was an error while loading. Please reload this page.
Extending the previous example, an action will occur during the transition from STATE_OFF to STATE_ON. For this reason we define an action:
public class TurnLightsOnAction extends AbstractAction { @Override public void execute(StateContext context) throws ActionException { System.out.println("Action: Turned the lights on!"); } }
<bean id="actionTurnLightsOn" class=" gr.ekt.fsmengine.example2.TurnLightsOnAction" />
And we associate the action with the transition.
<!-- Transitions --> <bean id="transition" class="gr.ekt.fsmengine.api.DefaultTransition"> <property name="fromState" ref="stateOff" /> <property name="toState" ref="stateOn" /> <property name="actions"> <list> <ref bean="actionTurnLightsOn"/> </list> </property> </bean>
The complete declaration is under conf/context-example2.xml.
Run src/test/java/gr.ekt.fsmengine.example2.Run to see the execution flow.