Flowable入门系列文章190 - 使用ProcessEngineConfigurator进行高级Process Engine配置

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

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

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

这种配置器的一个例子是LDAP集成,其中配置器用于将缺省用户和组管理器类替换为能够处理LDAP用户存储器的类。所以基本上配置器允许改变或调整流程引擎相当沉重,是为非常先进的用例。另一个例子是将流程定义缓存与自定义版本进行交换:

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

Process Engine配置程序也可以使用ServiceLoader方法从类路径中自动发现。这意味着必须将一个具有配置程序实现的jar放在类路径中,该jar包含名为org.flowable.engine.cfg.ProcessEngineConfigurator的jar 文件中的META-INF / services文件夹。该文件的内容需要是自定义实现的完全限定类名。当进程引擎启动时,日志记录将显示这些配置程序被发现:

INFO org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl -
找到1个可自动发现的过程引擎配置程序 INFO
org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl -
找到1个Process Engine配置程序总数: INFO
org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl -
类org.flowable.MyCustomConfigurator

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

上面文章来自盘古BPM研究院:http://vue.pangubpm.com/
文章翻译提交:https://github.com/qiudaoke/flowable-userguide
了解更多文章可以关注微信公众号:
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值