activiti框架API使用技巧

avatar
作者
猴君
阅读量:0

  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框架。

广告一刻

为您即时展示最新活动产品广告消息,让您随时掌握产品活动新动态!