-
Notifications
You must be signed in to change notification settings - Fork 3
Example 2: A simple action
Nikolaos Pougounias edited this page Jul 29, 2014
·
1 revision
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.
