Flowable 6.6.0 BPMN用户指南 - 17 高级用例 - 17.6 采用ProcessEngineConfigurator 进行高级的流程引擎配置

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


《Flowable 6.6.0 BPMN用户指南》

1. 入门
2. 配置
3 The Flowable API
4 Flowable 6.6.0 BPMN用户指南 - (4)Spring集成
5 Spring Boot
6 部署
7 BPMN 2.0简介
8 BPMN 2.0的构造
9 表单(Forms)
10 流程实例迁移
11 JPA
12 历史(History)
13 身份管理(Identity management)
14 REST API
15 CDI集成
16 LDAP集成
17 高级用例

有关Flowable的更多文档,参见:

《Flowable文档大全》


17.6 采用ProcessEngineConfigurator 进行高级的流程引擎配置(Advanced Process Engine configuration with a ProcessEngineConfigurator)

An advanced way of hooking into the process engine configuration is through the use of a ProcessEngineConfigurator. The idea is that an implementation of the org.flowable.engine.cfg.ProcessEngineConfigurator interface is created and injected into the process engine configuration:

挂接流程引擎配置的一种高级方法是使用ProcessEngineConfigurator。我们的想法是创建org.flowable.engine.cfg.ProcessEngineConfigurator接口的实现,并将其注入流程引擎配置中:

<bean id="processEngineConfiguration" class="...SomeProcessEngineConfigurationClass">

    ...

    <property name="configurators">
        <list>
            <bean class="com.mycompany.MyConfigurator">
                ...
            </bean>
        </list>
    </property>

    ...

</bean>

There are two methods required to implement this interface. The configure method, which gets a ProcessEngineConfiguration instance as parameter. The custom configuration can be added this way, and this method will guaranteed be called before the process engine is created, but after all default configuration has been done. The other method is the getPriority method, which allows for ordering the configurators in the case where some configurators are dependent on each other.

实现这个接口需要两种方法。configure 方法,它获取ProcessEngineConfiguration 实例作为参数。可以用这种方式添加自定义配置,并且可以保证在创建流程引擎之前,但在完成所有默认配置之后,调用此方法。另一种方法是getPriority 方法,它允许在某些配置程序相互依赖的情况下对配置器(configurator)进行排序。

An example of such a configurator is the LDAP integration, where the configurator is used to replace the default user and group manager classes with one that is capable of handling an LDAP user store. So basically a configurator allows to change or tweak the process engine quite heavily and is meant for very advanced use cases. Another example is to swap the process definition cache with a customized version:

这种配置器的一个例子是LDAP集成,配置器用于将默认的用户和组管理器类替换为能够处理LDAP用户存储的类。因此,基本上,配置器允许对流程引擎进行相当大的更改或调整,这意味着它适用于非常高级的用例。另一个示例是使用自定义版本交换流程定义缓存:

public class ProcessDefinitionCacheConfigurator extends AbstractProcessEngineConfigurator {

    public void configure(ProcessEngineConfigurationImpl processEngineConfiguration) {
            MyCache myCache = new MyCache();
            processEngineConfiguration.setProcessDefinitionCache(enterpriseProcessDefinitionCache);
    }

}

Process Engine configurators can also be auto discovered from the classpath using the ServiceLoader approach. This means that a jar with the configurator implementation must be put on the classpath, containing a file in the META-INF/services folder in the jar called org.flowable.engine.cfg.ProcessEngineConfigurator. The content of the file needs to be the fully qualified classname of the custom implementation. When the process engine is booted, the logging will show that these configurators are found:

还可以使用ServiceLoader 方法从classpath(类路径)自动发现流程引擎配置器。这意味着类路径(classpath)上必须放置了带有配置器实现的jar,在jar中的META-INF/services文件夹中包含一个文件org.flowable.engine.cfg.ProcessEngineConfigurator。 文件的内容必须是自定义实现的完全限定类名。当进程引擎启动时,日志记录将显示找到了以下配置器:

INFO  org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl  - Found 1 auto-discoverable Process Engine Configurators
INFO  org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl  - Found 1 Process Engine Configurators in total:
INFO  org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl  - class org.flowable.MyCustomConfigurator
Note that this ServiceLoader approach might not work in certain environments. It can be explicitly disabled using the enableConfiguratorServiceLoader property of the ProcessEngineConfiguration (true by default).

请注意,这种ServiceLoader方法在某些环境中可能不起作用。可以使用ProcessEngineConfiguration的enableConfiguratorServiceLoader 属性显式禁用它(默认为true)。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

月满闲庭

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值