ProcessEngine processEngine = new Configuration() .setResource("my-own-configuration-file.xml") .buildProcessEngine();
實際開發中咱們通常經過spring配置文件經過相關方法獲取。java
RepositoryService repositoryService = processEngine.getRepositoryService(); ExecutionService executionService = processEngine.getExecutionService(); TaskService taskService = processEngine.getTaskService(); HistoryService historyService = processEngine.getHistoryService(); ManagementService managementService = processEngine.getManagementService();
RepositoryService 包含了用來管理髮布資源的全部方法。在第一個例子中,咱們會使用web
RepositoryService 從classpath 中部署一個流程資源。spring
String deploymentid = repositoryService.createDeployment() .addResourceFromClasspath("org/jbpm/examples/services/Order.jpdl.xml") .deploy();
下面是爲流程定義啓動一個新的流程實例的最簡單也是最經常使用的方法:ui
ProcessInstance processInstance = executionService.startProcessInstanceByKey("ICL");
上面service 的方法會去查找key 爲ICL 的最新版本的流程定義, 而後在最新的流程定義裏啓動spa
流程實例。code
當insurance claim 流程部署了一個新版本, startProcessInstanceByKey 方法會自動切換到最xml
新部署的版本。資源
executionService.deleteProcessInstanceCascade(processInstance.getId());
executionService.endProcessInstance(processInstance.getId(), "cancle");