FoxBPM针对以前fixflow5.2版本流程定义进行整改优化,实现资源独立发布处理。
FoxBPM流程定义发布资源包括:
1):bpmn、png文件
2):bpmn文件
优化后的代码结构:
发布器统一接口Deployer
BpmnDeployer --- 发布bpmn资源
PngDeployer --- 支持自动生成png资源
所有发布器统一由发布管理器DeploymentManager管理调用
protected List<Deployer> deployers; public void deploy(DeploymentEntity deployment) { for (Deployer deployer : deployers) { deployer.deploy(deployment); } }
优点:可扩展,代码解耦,资源的发布独立处理
流程图:
引擎中初始化发布器
protected void initDeployers() { if (this.deployers == null) { this.deployers = new ArrayList<Deployer>(); if (customPreDeployers != null) { this.deployers.addAll(customPreDeployers); } this.deployers.addAll(getDefaultDeployers()); if (customPostDeployers != null) { this.deployers.addAll(customPostDeployers); } } if (deploymentManager == null) { deploymentManager = new DeploymentManager(); deploymentManager.setDeployers(deployers); deploymentManager.setProcessDefinitionCache(processDefinitionCache); } }
引擎创建系统默认bpmn发布器
protected Collection<? extends Deployer> getDefaultDeployers() { List<Deployer> defaultDeployers = new ArrayList<Deployer>(); if (bpmnDeployer == null) { // 添加部署的时候自动启动流程实例 功能,修改时间 2014-06-24 bpmnDeployer = new BpmnDeployer(); } if (processModelParseHandler == null) { processModelParseHandler = (ProcessModelParseHandler) ReflectUtil.instantiate("org.foxbpm.engine.impl.bpmn.parser.BpmnParseHandlerImpl"); } bpmnDeployer.setProcessModelParseHandler(processModelParseHandler); defaultDeployers.add(bpmnDeployer); return defaultDeployers; }
FoxBPM默认提供BpmnDeployer、PngDeployer两种发布器,
其中BpmnDeployer是系统预置,PngDeployer是系统提供可选的。
发布器调用顺序:系统--->自定义
BpmnDeployer发布器主要处理bpmn资源发布和更新,其中很重要一点就是将流程定义ID向后传递。
// 提供给其他发布器使用 deployment.addProperty(Constant.PROCESS_DEFINE_ID, processDefinitionEntity.getId());
PngDeployer发布器通过BpmnDeployer传递的流程定义ID来实现资源发布和更新;
如果存在png资源那么就直接发布png资源,否则通过bpmn获取svg内容再转换成png资源然后再发布。
另外fixflow还支持用户自定义发布,可以在spring中注入或者通过引擎设置
<!-- 流程引擎配置 --> <bean id="processEngineConfigurationSpring" class="org.foxbpm.engine.spring.ProcessEngineConfigurationSpring"> <property name="dataSourceManager" ref="foxbpmDataSourceManager" /> <property name="transactionManager" ref="foxbpmTransactionManager" /> <property name="foxbpmScheduler" ref="foxbpmScheduler"></property> <!-- 可选的发布处理行为,可卸载 --> <property name="customPostDeployers"> <list> <bean class="org.foxbpm.engine.impl.bpmn.deployer.PngDeployer"/> </list> </property> </bean>
用户可以自定义发布器继承 Deployer,并通过以上sping注入或者通过引擎设置
关于FoxBPM相关内容详细请参考github官方https://github.com/FoxBPM/