Source:
public ProcessDefinition buildProcessDefinition(String deploymentId, String bpmn2Content, KieContainer kieContainer, boolean cache) throws IllegalArgumentException { if (StringUtils.isEmpty(bpmn2Content)) { return null; } validateNonEmptyDeploymentIdAndProcessId(deploymentId, "no proc id"); KnowledgeBuilder kbuilder = null; if (kieContainer != null && kieContainer.getClassLoader() != null ) { KnowledgeBuilderConfigurationImpl pconf = new KnowledgeBuilderConfigurationImpl(kieContainer.getClassLoader()); kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(pconf); } else { kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); } kbuilder.add(new ByteArrayResource(bpmn2Content.getBytes()), ResourceType.BPMN2); if (kbuilder.hasErrors()) { for(KnowledgeBuilderError error: kbuilder.getErrors()){ logger.error("Error: {}", error.getMessage()); } logger.debug("Process Cannot be Parsed! \n \n", bpmn2Content); return null; } KnowledgePackage pckg = kbuilder.getKnowledgePackages().iterator().next(); Process process = pckg.getProcesses().iterator().next(); ProcessDescriptor helper = (ProcessDescriptor) process.getMetaData().get("ProcessDescriptor"); ProcessAssetDesc definition = helper.getProcess(); if( kieContainer != null && helper.hasUnresolvedReusableSubProcessNames() ) { helper.resolveReusableSubProcessNames(kieContainer.getKieBase().getProcesses()); } definition.setReusableSubProcesses(helper.getReusableSubProcesses()); if (cache) { Map<String, ProcessDescriptor> definitions = null; synchronized (definitionCache) { definitions = definitionCache.get(deploymentId); if (definitions == null) { definitions = new ConcurrentHashMap<String, ProcessDescriptor>(); definitionCache.put(deploymentId, definitions); } definitions.put(process.getId(), helper); } } return definition; }

Target:
public ProcessDefinition buildProcessDefinition(String deploymentId, String bpmn2Content, KieContainer kieContainer, boolean cache) throws IllegalArgumentException { if (StringUtils.isEmpty(bpmn2Content)) { return null; } validateNonEmptyDeploymentIdAndProcessId(deploymentId, "no proc id"); KnowledgeBuilder kbuilder = null; if (kieContainer != null && kieContainer.getClassLoader() != null ) { KnowledgeBuilderConfigurationImpl pconf = new KnowledgeBuilderConfigurationImpl(kieContainer.getClassLoader()); kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(pconf); } else { kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); } kbuilder.add(new ByteArrayResource(bpmn2Content.getBytes()), ResourceType.BPMN2); if (kbuilder.hasErrors()) { for(KnowledgeBuilderError error: kbuilder.getErrors()){ logger.error("Error: {}", error.getMessage()); } logger.debug("Process Cannot be Parsed! \n \n", bpmn2Content); return null; } KnowledgePackage pckg = kbuilder.getKnowledgePackages().iterator().next(); Process process = pckg.getProcesses().iterator().next(); ProcessDescriptor helper = (ProcessDescriptor) process.getMetaData().get("ProcessDescriptor"); ProcessAssetDesc definition = helper.getProcess(); if( kieContainer != null && helper.hasUnresolvedReusableSubProcessNames() ) { helper.resolveReusableSubProcessNames(kieContainer.getKieBase().getProcesses()); } definition.setReusableSubProcesses(helper.getReusableSubProcesses()); if (cache) { Map<String, ProcessDescriptor> definitions = null; synchronized (definitionCache) { Map<String, ProcessDescriptor> newDef = new ConcurrentHashMap<String, ProcessDescriptor>(); definitions = definitionCache.putIfAbsent(deploymentId, newDef); if( definitions == null ) { definitions = newDef; } definitions.put(process.getId(), helper); } } return definition; }