package com.jiaocaigen001.helloworld;
import java.util.List;
import org.jbpm.api.*;
import junit.framework.TestCase;
/**
* 流程定义
* @author leiwei 2012-3-19
*
*/
public class HelloWorld extends TestCase {
//流程引擎
ProcessEngine processEngine;
public HelloWorld() {
processEngine = Configuration.getProcessEngine();
}
public void testDeploy() {
//流程资源服务的接口,如流程定义发布、查询、删除等
RepositoryService repositoryService = processEngine.getRepositoryService();
/**
* 发布流程定义
*/
String deploymentId = repositoryService.createDeployment()
.addResourceFromClasspath("helloworld.jpdl.xml").deploy();
/**
* 查看流程定义
*/
List<ProcessDefinition> processDefinitionsList = repositoryService
.createProcessDefinitionQuery().list();
for (ProcessDefinition processDefinition : processDefinitionsList) {
System.out.println("已经创建的流程引擎ID:"+processDefinition.getId());
}
/**
* 删除流程定义
*/
repositoryService.deleteDeployment(deploymentId);
System.out.println("删除后还剩多少个流程引擎:"+""+
repositoryService.createProcessDefinitionQuery().list().size());
}
}