Spring 状态机和 xml 配置

Spring Statemachine and xml Configuration

我是 Spring Statemachine 框架的新手。可以在经典 XML 配置文件上使用配置吗?状态、事件和动作会更清晰。

根据我的文档:

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); }

此示例使用 spring 注释进行配置。我会通过 XML spring 配置文件来配置它。

还没有,但我们有一些 github 问题来跟踪这些请求,即 gh78