我想包括几个StateMachine使用StateMachineFactory. 但是@EnableStateMachineFactory注释允许命名工厂。如何命名每个 Config(即 extends EnumStateMachineConfigurerAdapter)?
否则,如果可能的话,有一个如何setMachineID在配置定义中使用该方法的示例将很有用。
我想包括几个StateMachine使用StateMachineFactory. 但是@EnableStateMachineFactory注释允许命名工厂。如何命名每个 Config(即 extends EnumStateMachineConfigurerAdapter)?
否则,如果可能的话,有一个如何setMachineID在配置定义中使用该方法的示例将很有用。
将这些enable注释与 Spring `@Configuration' 类一起定义只是定义了在应用程序上下文中注册的 bean 名称。用例子最容易解释:
@EnableStateMachine
StateMachine作为豆stateMachine。
@EnableStateMachine(name = "fooMachine")
StateMachine作为豆fooMachine。
@EnableStateMachine(name = {StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, "fooMachine"})
StateMachine作为stateMachine具有 bean 别名的 bean fooMachine。
@EnableStateMachineFactory
StateMachineFactory作为豆stateMachineFactory。
@EnableStateMachineFactory(name = "fooMachineFactory")
StateMachineFactory作为豆fooMachineFactory。
@EnableStateMachineFactory(name = {StateMachineSystemConstants.DEFAULT_ID_STATEMACHINEFACTORY, "fooMachineFactory"})
StateMachineFactory作为stateMachineFactory具有 bean 别名的 bean fooMachineFactory。
除此之外,@Configuration类的名称(扩展 StateMachineConfigurerAdapter)无关紧要。认为在 Spring 中,一个@Configuration类也被创建为 bean,这意味着下面的类将作为 bean 存在于 Spring Application Context 中myConfig.MachineFactoryConfig。在 Spring 中要记住一件事,因为命名错误的类可能会导致 bean 覆盖!
public class MyConfig {
@Configuration
@EnableStateMachineFactory
public static class MachineFactoryConfig extends StateMachineConfigurerAdapter<String, String> {
}
}
我machineId刚刚在 docs State Machine ID中添加了一个新部分。(仅在快照构建中,直到我们发布下一个版本)