Flowable 6.6.0 BPMN用户指南 - (4)Spring集成 - 4.3 表达式(Expressions)

2022-07-25,,,,

Flowable 6.6.0 BPMN用户指南

1. 入门

2. 配置

3 The Flowable API

4 Flowable 6.6.0 BPMN用户指南 - (4)Spring集成

4.1 ProcessEngineFactoryBean
4.2 事务
4.3 表达式(Expressions)
4.4 自动资源部署(Automatic resource deployment)
4.5 单元测试
4.6 使用Hibernate 4.2.x的JPA

Flowable 6.6.0 用户指南相关文档下载

《精编Flowable 6.6.0 应用程序指南中文PDF版》
《精编Flowable 6.6.0 表单用户指南中文PDF版》

有关Flowable更多文档,参见:

《Flowable文档大全》

4.3 表达式(Expressions)

When using the ProcessEngineFactoryBean, all expressions in the BPMN processes will also ‘see’ all the Spring beans, by default. It’s possible to limit the beans (even none) you want to expose in expressions using a map that you can configure. The example below exposes a single bean (printer), available to use under the key “printer”. To have NO beans exposed at all, just pass an empty list as ‘beans’ property on the SpringProcessEngineConfiguration. When no ‘beans’ property is set, all Spring beans in the context will be available.

当使用ProcessEngineFactoryBean时,默认情况下,BPMN流程中的所有表达式(expressions )也将“看到”所有Spring bean。使用你配置的map可以限制要在表达式中公开的bean(即使没有)。下面的示例公开了一个bean(printer),可以在键“printer”下使用。要完全不公开bean,只需将空列表作为“beans”属性传递到SpringProcessEngineConfiguration即可。当没有设置’beans’属性时,上下文中的所有Spring bean都将可用。

<bean id="processEngineConfiguration" class="org.flowable.spring.SpringProcessEngineConfiguration">
  ...
  <property name="beans">
    <map>
      <entry key="printer" value-ref="printer" />
    </map>
  </property>
</bean>

<bean id="printer" class="org.flowable.examples.spring.Printer" />

Now the exposed beans can be used in expressions: for example, the SpringTransactionIntegrationTest hello.bpmn20.xml shows how a method on a Spring bean can be invoked using a UEL method expression:

现在公开的bean可以在表达式中使用:例如,SpringTransactionIntegrationTest hello.bpmn20.xml展示了如何使用UEL方法表达式调用Spring bean上的方法:

<definitions id="definitions">

  <process id="helloProcess">

    <startEvent id="start" />
    <sequenceFlow id="flow1" sourceRef="start" targetRef="print" />

    <serviceTask id="print" flowable:expression="#{printer.printMessage()}" />
    <sequenceFlow id="flow2" sourceRef="print" targetRef="end" />

    <endEvent id="end" />

  </process>

</definitions>

其中Printer如下:

public class Printer {

  public void printMessage() {
    System.out.println("hello world");
  }
}

Spring bean配置(如上所示)如下所示:

<beans>
  ...

  <bean id="printer" class="org.flowable.examples.spring.Printer" />

</beans>

本文地址:https://blog.csdn.net/weixin_52265084/article/details/111879208

《Flowable 6.6.0 BPMN用户指南 - (4)Spring集成 - 4.3 表达式(Expressions).doc》

下载本文的Word格式文档,以方便收藏与打印。