2016-01-20 110 views
0

我是Spring Statemachine框架中的新成員。有可能在傳統的XML配置文件上使用配置?狀態,事件和行動將更加清晰。Spring Statemachine和xml配置

+0

你的問題不是很清楚,請詳細說明您正在使用的用例,樣本數據和實例問。 – hazardous

+0

在答案1有回覆 –

回答

0

還沒有,但我們有一些問題,GitHub的跟蹤這些請求,即gh78

+0

謝謝Janne。你打算開發這個功能嗎? –

+0

希望在某些時候,無論是我還是其他人。問題是有限的時間/資源等。 –

0

通過文檔我有:

static enum States { STATE1, STATE2 } static enum Events { EVENT1, EVENT2 } @Configuration @EnableStateMachine static class Config1 extends EnumStateMachineConfigurerAdapter<States, Events> { @Override public void configure(StateMachineStateConfigurer<States, Events> states) throws Exception { states .withStates() .initial(States.STATE1) .states(EnumSet.allOf(States.class)); } @Override public void configure(StateMachineTransitionConfigurer<States, Events> transitions) throws Exception { transitions .withExternal() .source(States.STATE1).target(States.STATE2) .event(Events.EVENT1) .and() .withExternal() .source(States.STATE2).target(States.STATE1) .event(Events.EVENT2); } } @WithStateMachine static class MyBean { @OnTransition(target = "STATE1") void toState1() { } @OnTransition(target = "STATE2") void toState2() { } } static class MyApp { @Autowired StateMachine<States, Events> stateMachine; void doSignals() { stateMachine.start(); stateMachine.sendEvent(Events.EVENT1); stateMachine.sendEvent(Events.EVENT2); }

本示例爲配置使用彈簧註釋。我會通過XML spring配置文件來配置它。