【发布时间】:2019-02-22 08:45:53
【问题描述】:
在我在网上查到的所有示例中,StateMachine 都是静态配置的
@Override
public void configure(StateMachineTransitionConfigurer<BookStates, BookEvents> transitions) throws Exception {
transitions
.withExternal()
.source(BookStates.AVAILABLE)
.target(BookStates.BORROWED)
.event(BookEvents.BORROW)
.and()
.withExternal()
.source(BookStates.BORROWED)
.target(BookStates.AVAILABLE)
.event(BookEvents.RETURN)
.and()
.withExternal()
.source(BookStates.AVAILABLE)
.target(BookStates.IN_REPAIR)
.event(BookEvents.START_REPAIR)
.and()
.withExternal()
.source(BookStates.IN_REPAIR)
.target(BookStates.AVAILABLE)
.event(BookEvents.END_REPAIR);
}
我想通过从数据库中获取源、目标、事件来“动态”配置 StateMachine,然后循环遍历列表以“流畅”的方式进行配置。
这可能吗?
【问题讨论】:
标签: spring java-8 spring-statemachine