【问题标题】:Can we use UmlStateMachineModelFactory inside a StateMachineBuilder我们可以在 StateMachineBuilder 中使用 UmlStateMachineModelFactory
【发布时间】:2016-08-08 11:12:18
【问题描述】:

我正在使用 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 模型中给出入口动作类的名称,以便为每个阶段附加入口动作吗?如果是这样,我怎么能在 eclipse papyrus 中做到这一点。

提前致谢!

【问题讨论】:

    标签: spring-statemachine


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 2021-01-03
      • 2016-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-31
      • 2020-03-21
      • 2018-12-25
      • 2011-08-21
      相关资源
      最近更新 更多