首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 企业软件 > 行业软件 >

JBPM4.4 施用之流程管理初探

2012-08-11 
JBPM4.4 使用之流程管理初探注:本篇只做简略的入门样例,更深入的介绍,请关注之后的博客内容。?管理流程定义

JBPM4.4 使用之流程管理初探

注:本篇只做简略的入门样例,更深入的介绍,请关注之后的博客内容。

?

管理流程定义

import java.util.List;import org.jbpm.api.Configuration;import org.jbpm.api.ExecutionService;import org.jbpm.api.ProcessEngine;import org.jbpm.api.ProcessInstance;import junit.framework.TestCase;public class ProcessInstanceTest extends TestCase {ProcessEngine processEngine;public ProcessInstanceTest() {processEngine = Configuration.getProcessEngine();}@Overrideprotected void setUp() throws Exception {processEngine.getRepositoryService().createDeployment().addResourceFromClasspath("helloworld.jpdl.xml").deploy();}/** * 流程实例state节点向下执行 */public void testProcessInstance(){ExecutionService es= processEngine.getExecutionService();//流程实例ProcessInstance pi = es.startProcessInstanceByKey("helloworld");//state向下执行pi= es.signalExecutionById(pi.getId());System.out.println("pi.isEnded"+pi.isEnded());}/** * 终止流程实例 */public void testProcessInstanceEnd(){ExecutionService es= processEngine.getExecutionService();//流程实例ProcessInstance pi = es.startProcessInstanceByKey("helloworld");//终止流程实例es.endProcessInstance(pi.getId(), "结束流程");}/** * 删除流程实例 */public void testProcessInstanceDel(){ExecutionService es= processEngine.getExecutionService();//流程实例ProcessInstance pi = es.startProcessInstanceByKey("helloworld");//删除流程实例es.deleteProcessInstanceCascade(pi.getId());}/** * 流程实例列表 */public void testProcessInstanceList(){ExecutionService es= processEngine.getExecutionService();//流程实例ProcessInstance pi = null;for (int i = 0; i < 10; i++) {pi= es.startProcessInstanceByKey("helloworld");}//查询流程实例列表List<ProcessInstance> list= es.createProcessInstanceQuery().list();//输出列表数到控制台System.out.println("list.size:"+list.size());}}

?

?

以下是测试用的工程,有需要的朋友可以下载运行看看结果!当然环境配置是必须的,关于环境配置请参考我的上一篇博客。

?

热点排行