// 在部署流程的过程中,就会调用该方法来解析流程protectedBpmnParsecreateBpmnParseFromResource(ResourceEntityresource){StringresourceName=resource.getName();// 流程文件的字节流ByteArrayInputStreaminputStream=newByteArrayInputStream(resource.getBytes());// 创建解析对象,设置字节流BpmnParsebpmnParse=bpmnParser.createParse().sourceInputStream(inputStream).setSourceSystemId(resourceName).deployment(deployment).name(resourceName);// 设置校验参数if(deploymentSettings!=null){// Schema validation if neededif(deploymentSettings.containsKey(DeploymentSettings.IS_BPMN20_XSD_VALIDATION_ENABLED)){bpmnParse.setValidateSchema((Boolean)deploymentSettings.get(DeploymentSettings.IS_BPMN20_XSD_VALIDATION_ENABLED));}// Process validation if neededif(deploymentSettings.containsKey(DeploymentSettings.IS_PROCESS_VALIDATION_ENABLED)){bpmnParse.setValidateProcess((Boolean)deploymentSettings.get(DeploymentSettings.IS_PROCESS_VALIDATION_ENABLED));}}else{// On redeploy, we assume it is validated at the first deploybpmnParse.setValidateSchema(false);bpmnParse.setValidateProcess(false);}// 执行解析流程bpmnParse.execute();returnbpmnParse;}
// 执行解析流程publicBpmnParseexecute(){try{ProcessEngineConfigurationImplprocessEngineConfiguration=Context.getProcessEngineConfiguration();BpmnXMLConverterconverter=newBpmnXMLConverter();booleanenableSafeBpmnXml=false;Stringencoding=null;if(processEngineConfiguration!=null){enableSafeBpmnXml=processEngineConfiguration.isEnableSafeBpmnXml();encoding=processEngineConfiguration.getXmlEncoding();}// 解析 xml 元素,转换为 java 对象,会调用 convertToBpmnModel 方法bpmnModel=converter.convertToBpmnModel(streamSource,validateSchema,enableSafeBpmnXml,encoding);...// Attach logic to the processes (eg. map ActivityBehaviors to bpmn model elements)// 应用解析器,这个很重要applyParseHandlers();// Finally, process the diagram interchange infoprocessDI();}catch(Exceptione){...}returnthis;}