连接到流程引擎配置的高级方法是使用 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
了解更多文章可以关注微信公众号:
在这里插入图片描述

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐