溫馨提示×

activiti框架API使用技巧

小樊
83
2024-08-03 06:20:09
欄目: 編程語言

  1. 流程引擎的初始化
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
  1. 部署流程定義
RepositoryService repositoryService = processEngine.getRepositoryService();
Deployment deployment = repositoryService.createDeployment()
  .addClasspathResource("processes/my-process.bpmn20.xml")
  .deploy();
  1. 啟動流程實例
RuntimeService runtimeService = processEngine.getRuntimeService();
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("my-process");
  1. 查詢?nèi)蝿?wù)
TaskService taskService = processEngine.getTaskService();
List<Task> tasks = taskService.createTaskQuery().taskAssignee("kermit").list();
  1. 完成任務(wù)
taskService.complete(task.getId());
  1. 查詢流程實例
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId("my-process-id").singleResult();
  1. 查詢歷史流程實例
HistoryService historyService = processEngine.getHistoryService();
List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().finished().list();
  1. 獲取流程定義信息
RepositoryService repositoryService = processEngine.getRepositoryService();
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processInstance.getProcessDefinitionId()).singleResult();

這些是使用Activiti框架API的基本技巧,可以幫助您在實際開發(fā)中更好地使用Activiti框架。

0