2

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

但是由于一些需求变化,我的配置几乎是不变的,现在我想使用 eclipse uml 建模,因为我不再需要动态或以编程方式构建状态机。为了避免大的代码返工,我想在 builder 中使用 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模型中给出入口动作类的名称,以便为每个阶段附加入口动作吗?如果是这样,我怎么能在日食纸莎草纸中做到这一点。

提前致谢!

4

1 回答 1

1

文档可能对此有点不清楚(特别是如果用户不熟悉纸莎草纸和 uml 概念)。我将从研究 uml xml 测试文件中的 uml 测试源开始,如何从 uml 将动作/防护引用到运行时解析中。当您看到那些使用真正的纸莎草 uml 建模器时,事情会变得更加清晰。

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

这个测试testSimpleFlat2()将注册额外的动作/守卫。这些是通过接口解析的,如果已知,则StateMachineComponentResolver内部实例DefaultStateMachineComponentResolver将解析,但用户可以添加辅助项,如该测试中所示。BeanFactoryDefaultStateMachineComponentResolver

于 2016-08-09T07:42:09.913 回答