java流程管理 之 jbpm流程執行個體 發布、查看、終止、刪除

來源:互聯網
上載者:User
package com.jiaocaigen002.processinstance;import java.util.List;import org.jbpm.api.*;import junit.framework.TestCase;/** * 流程執行個體 * @author leiwei 2012-3-20 * */public class ProcessInstanceTest extends TestCase {//流程引擎ProcessEngine processEngine;public ProcessInstanceTest() {processEngine = Configuration.getProcessEngine();}/** *  發布流程定義 */protected void setUp() {//流程資源服務的介面,如流程定義發布、查詢、刪除等processEngine.getRepositoryService().createDeployment()                .addResourceFromClasspath("helloworld.jpdl.xml").deploy();}/** * 發布新流程 */public void newProcessInstance() {//用於操作人工任務的服務,可以進行任務建立、查詢、擷取、提交完成、儲存、刪除等操作ExecutionService executionService = processEngine.getExecutionService();ProcessInstance processInstance = executionService.startProcessInstanceByKey("helloworld");//查看流程是否已經結束System.out.println("流程是否已經結束:"+processInstance.isEnded());//直接跳過等待,直接結束processInstance = executionService.signalExecutionById(processInstance.getId());System.out.println("流程是否已經結束:"+processInstance.isEnded());}/** * 終止流程 */public void endProcessInstance() {ExecutionService executionService = processEngine.getExecutionService();ProcessInstance processInstance = executionService.startProcessInstanceByKey("helloworld");executionService.endProcessInstance(processInstance.getId(), "cancle");}/** * 刪除流程 */public void deleteProcessInstance() {ExecutionService executionService = processEngine.getExecutionService();ProcessInstance processInstance = executionService.startProcessInstanceByKey("helloworld");executionService.deleteProcessInstanceCascade(processInstance.getId());}/** * 查看流程 */public void selectProcessInstance() {ExecutionService executionService = processEngine.getExecutionService();ProcessInstance processInstance1 = executionService.startProcessInstanceByKey("helloworld");ProcessInstance processInstance2 = executionService.startProcessInstanceByKey("helloworld");List<ProcessInstance> processInstanceList= executionService                            .createProcessInstanceQuery().list();for (ProcessInstance processInstance : processInstanceList) {System.out.println("流程的個數:"+processInstance.getId());}}}


 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.