我想包括几个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中添加了一个新部分。(仅在快照构建中,直到我们发布下一个版本)