activiti 臨時筆記mark

public class TenMinuteTutorial {

  public static void main(String[] args) {

    // Create Activiti process engine
    ProcessEngine processEngine = ProcessEngineConfiguration
      .createStandaloneProcessEngineConfiguration()
      .buildProcessEngine();

    // Get Activiti services
    RepositoryService repositoryService = processEngine.getRepositoryService();
    RuntimeService runtimeService = processEngine.getRuntimeService();

    // Deploy the process definition
    repositoryService.createDeployment()
      .addClasspathResource("FinancialReportProcess.bpmn20.xml")
      .deploy();

    // Start a process instance
    String procId = runtimeService.startProcessInstanceByKey("financialReport").getId();

    // Get the first task
    TaskService taskService = processEngine.getTaskService();
    List<Task> tasks = taskService.createTaskQuery().taskCandidateGroup("accountancy").list();
    for (Task task : tasks) {
      System.out.println("Following task is available for accountancy group: " + task.getName());

      // claim it
      taskService.claim(task.getId(), "fozzie");
    }

    // Verify Fozzie can now retrieve the task
    tasks = taskService.createTaskQuery().taskAssignee("fozzie").list();
    for (Task task : tasks) {
      System.out.println("Task for fozzie: " + task.getName());

      // Complete the task
      taskService.complete(task.getId());
    }

    System.out.println("Number of tasks for fozzie: "
            + taskService.createTaskQuery().taskAssignee("fozzie").count());

    // Retrieve and claim the second task
    tasks = taskService.createTaskQuery().taskCandidateGroup("management").list();
    for (Task task : tasks) {
      System.out.println("Following task is available for accountancy group: " + task.getName());
      taskService.claim(task.getId(), "kermit");
    }

    // Completing the second task ends the process
    for (Task task : tasks) {
      taskService.complete(task.getId());
    }

    // verify that the process is actually finished
    HistoryService historyService = processEngine.getHistoryService();
    HistoricProcessInstance historicProcessInstance =
      historyService.createHistoricProcessInstanceQuery().processInstanceId(procId).singleResult();
    System.out.println("Process instance end time: " + historicProcessInstance.getEndTime());
  }

}

  

各個Service的做用:java

RepositoryServiceui

管理流程定義spa

RuntimeServiceorm

執行管理,包括啓動、推動、刪除流程實例等操做xml

TaskService對象

任務管理blog

HistoryService圖片

歷史管理(執行完的數據的管理)ci

IdentityService文檔

組織機構管理

FormService

一個可選服務,任務表單管理

ManagerService

 

 

1:RepositoryService

是Activiti的倉庫服務類。所謂的倉庫指流程定義文檔的兩個文件:bpmn文件和流程圖片。

1)     產生方式

 

2)     能夠產生DeploymentBuilder,用來定義流程部署的相關參數

 

3)     刪除流程定義

 

2:RuntimeService

是activiti的流程執行服務類。能夠從這個服務類中獲取不少關於流程執行相關的信息。

3:TaskService

是activiti的任務服務類。能夠從這個類中獲取任務的信息。

4:HistoryService

是activiti的查詢歷史信息的類。在一個流程執行完成後,這個對象爲咱們提供查詢歷史信息。

相關文章
相關標籤/搜索