阅读量:0
- 流程引擎的初始化
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
- 部署流程定义
RepositoryService repositoryService = processEngine.getRepositoryService(); Deployment deployment = repositoryService.createDeployment() .addClasspathResource("processes/my-process.bpmn20.xml") .deploy();
- 启动流程实例
RuntimeService runtimeService = processEngine.getRuntimeService(); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("my-process");
- 查询任务
TaskService taskService = processEngine.getTaskService(); List<Task> tasks = taskService.createTaskQuery().taskAssignee("kermit").list();
- 完成任务
taskService.complete(task.getId());
- 查询流程实例
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId("my-process-id").singleResult();
- 查询历史流程实例
HistoryService historyService = processEngine.getHistoryService(); List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().finished().list();
- 获取流程定义信息
RepositoryService repositoryService = processEngine.getRepositoryService(); ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processInstance.getProcessDefinitionId()).singleResult();
这些是使用Activiti框架API的基本技巧,可以帮助您在实际开发中更好地使用Activiti框架。