温馨提示×

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. 查询任务
TaskService taskService = processEngine.getTaskService();
List<Task> tasks = taskService.createTaskQuery().taskAssignee("kermit").list();
  1. 完成任务
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的基本技巧,可以帮助您在实际开发中更好地使用Activiti框架。

0