我们可以在 StateMachineBuilder 中使用 UmlStateMachineModelFactory

Can we use UmlStateMachineModelFactory inside a StateMachineBuilder

我正在使用 StateMachineBuilder 创建状态机,因为我需要以编程方式使用它来配置状态和转换。

但是由于一些需求变化,我的配置几乎保持不变,现在我想使用 eclipse uml 建模,因为我不再需要动态或以编程方式构建状态机。 为了避免大的代码返工,我想到了在构建器中使用 UmlStateMachineModelFactory,如下所示。

Builder<String, String> builder = StateMachineBuilder
                .<String, String> builder();
        builder.configureConfiguration()
        .withConfiguration()
        .autoStartup(false)
        .listener(listener())
        .beanFactory(
                this.applicationContext.getAutowireCapableBeanFactory());



builder.configureModel().withModel().factory(new UmlStateMachineModelFactory("classpath:model2.uml"));

1) 在状态机中是否合法,如果合法,我如何为每个状态附加入口操作?

目前正在使用构建器我正在使用以下代码为每个状态附加进入操作

stateConfigurer.state("State1", this.state1EntryAction, null);

// State1EntryAction is  @Autowired inside my controller class  and
// State1EntryAction   implements Action<String, String> and
// annotated with @Component (org.springframework.stereotype.Component)

2) 我可以在 uml 模型中给出入口动作的名称 class,以便为每个阶段附加入口动作吗?如果是这样,我怎么能在 eclipse papyrus 中做到这一点。

提前致谢!

文档对此可能有点不清楚(特别是如果用户不熟悉 papyrus 和 uml 概念)。我首先研究 uml xml test files 中的 uml 测试源,actions/guards 如何从 uml 引用到运行时解析中。当您看到那些使用真正的 papyrus uml 建模器时,事情变得更加清晰。

默认情况下 guard/action 将解析为来自应用程序上下文的等效 bean 名称,但是有一种方法可以手动挂接其他实例(即,如果 guard/action 未定义为 bean)。

此测试 testSimpleFlat2() 将注册额外的 actions/guards。这些是通过 StateMachineComponentResolver 接口解析的,如果已知 DefaultStateMachineComponentResolver 的内部实例将从 BeanFactory 解析,但用户可以添加辅助 DefaultStateMachineComponentResolver,如该测试所示。