Activiti: 三种部署方式和几种启动方式
三种部署:
1.自动部署: <property name="deploymentResources" value="classpath*:/bpmn/*.bpmn"/>
<bean id="processEngineConfiguration" ref="dataSource"/> <property name="deploymentResources" value="classpath*:/bpmn/*.bpmn"/> <property name="transactionManager" ref="transactionManager"/> <property name="databaseSchemaUpdate" value="true"/> <property name="jobExecutorActivate" value="false"/> <property name="processDefinitionCacheLimit" value="10"/> <property name="activityFontName" value="${diagram.activityFontName}"/> <property name="labelFontName" value="${diagram.labelFontName}"/> </bean>
repositoryService.createDeployment() .addClasspathResource("bpmn/MyProcess.bpmn") .deploy();
@RequestMapping("/startModel") public ModelAndView startModel(@RequestParam("id") String id) { System.out.println("id=" + id); Deployment deployment = null; try { Model modelData = repositoryService.getModel(id); ObjectNode modelNode = (ObjectNode) new ObjectMapper().readTree( repositoryService.getModelEditorSource(modelData.getId()) ); byte[] bpmnBytes = null; BpmnModel model = new BpmnJsonConverter().convertToBpmnModel(modelNode); bpmnBytes = new BpmnXMLConverter().convertToXML(model); String processName = modelData.getName() + ".bpmn20.xml"; deployment = repositoryService.createDeployment() .name(modelData.getName()) .addString(processName, new String(bpmnBytes)) .deploy(); } catch (Exception e) { e.printStackTrace(); } String url = "redirect:/a/list.do"; return new ModelAndView(url); }
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProcess", variables); StartFormData formData = formService.getStartFormData(processInstance.getProcessDefinitionId());
Map<String, String> properties = new HashMap<String, String>(); ProcessInstance processInstance = formService.submitStartFormData(ProcessDefinitionId, properties);