上一篇:
第10篇:Flowable-BPMN操作流程部署、启动
https://blog.csdn.net/weixin_40816738/article/details/102902348
文章目录
- 一、问题描述
- 二、问题定位
- 三、解决方案
- 四、验证结果
一、问题描述
- 流程在部署的时候调用服务RepositoryService,该服务通过createDeployment,创建了一个DeploymentBuilder,由builder的deploy,问题代码如下:
inputStream=new FileInputStream(new File(filePath));DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().name("TEST_FLOW").addInputStream("flowname",inputStream);Deployment deployment= deploymentBuilder.deploy();
用后查看部署信息表ACT_RE_DEPLOYMENT有内容,如下图:
查询ACT_RE_PROCDEF表发现没有内容:
二、问题定位
跟踪代码进入类ParsedDeploymentBuilder,build函数如下:
public ParsedDeployment build() {List<ProcessDefinitionEntity> processDefinitions = new ArrayList();Map<ProcessDefinitionEntity, BpmnParse> processDefinitionsToBpmnParseMap = new LinkedHashMap();Map<ProcessDefinitionEntity, EngineResource> processDefinitionsToResourceMap = new LinkedHashMap();DeploymentEntity deploymentEntity = (DeploymentEntity)this.deployment;Iterator var5 = deploymentEntity.getResources().values().iterator();while(true) {EngineResource resource;do {if (!var5.hasNext()) {return new ParsedDeployment(deploymentEntity, processDefinitions, processDefinitionsToBpmnParseMap, processDefinitionsToResourceMap);}resource = (EngineResource)var5.next();} while(!this.isBpmnResource(resource.getName()));LOGGER.debug("Processing BPMN resource {}", resource.getName());BpmnParse parse = this.createBpmnParseFromResource(resource);Iterator var8 = parse.getProcessDefinitions().iterator();while(var8.hasNext()) {ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity)var8.next();processDefinitions.add(processDefinition);processDefinitionsToBpmnParseMap.put(processDefinition, parse);processDefinitionsToResourceMap.put(processDefinition, resource);}}}
看到调用了this.isBpmnResource(resource.getName()),我们输入的名字会进行校验,校验函数如下:
protected boolean isBpmnResource(String resourceName) {String[] var2 = ResourceNameUtil.BPMN_RESOURCE_SUFFIXES;int var3 = var2.length;for(int var4 = 0; var4 < var3; ++var4) {String suffix = var2[var4];if (resourceName.endsWith(suffix)) {return true;}}return false;}
其中资源后缀的定义如下:
public static final String[] BPMN_RESOURCE_SUFFIXES = new String[]{"bpmn20.xml", "bpmn"};
三、解决方案
调整资源名以bpmn或者bpmn20.xml结尾。调整如下:
repositoryService.createDeployment().name("TEST_FLOW").addInputStream("flowname.bpmn20.xml",inputStream);
四、验证结果
修改后重新调用,验证结果如下:
下一篇:
第12篇:Flowable-BPMN操作流程之用户任务UserTask
https://blog.csdn.net/weixin_40816738/article/details/102902596