本博文只是简要对JBPM4进行介绍,如需更详细内容请自行google
链接:
JBPM入门系列文章:
JBPM4入门——2.在eclipse中安装绘制jbpm流程图的插件
JBPM4入门——4.封装流程管理的工具类(JbpmUtil)
package com.test.test; import java.util.Iterator;
import java.util.List; import org.jbpm.api.ProcessDefinition;
import org.jbpm.api.ProcessDefinitionQuery;
import org.jbpm.api.ProcessInstance; import com.test.util.JbpmUtil; public class Test { /**
* 流程定义的发布
* @param jpdlFileName 流程定义的文件名。例如:hello.jpdl.xml
*/
public void deploy(String jpdlFileName){
JbpmUtil.getRepositoryService()
.createDeployment()
.addResourceFromClasspath(jpdlFileName)
.deploy();
} /**
* 流程定义的查询
*/
public void query(){
ProcessDefinitionQuery query
= JbpmUtil.getRepositoryService().createProcessDefinitionQuery();
List<ProcessDefinition> list = query.list();
for (Iterator iterator = list.iterator(); iterator.hasNext();) {
ProcessDefinition processDefinition = (ProcessDefinition) iterator
.next();
/**
* id:流程定义的id
* key:就是流程定义的文件名称 、相同的key下面有不同的id
* deploymentId:表达的是这次动作发布的时候数据库中存储的那条记录的主键id
*/
System.out.println("id:"+processDefinition.getId());
System.out.println("key:"+processDefinition.getKey());
System.out.println("deploymentId:"+processDefinition.getDeploymentId());
}
} /**
* 流程定义的删除
* @param deploymentId
*/
public void del(String deploymentId){
//deleteDeploymentCascade 级联删除:删除流程定义的时候把流程实例也删了..
JbpmUtil.getRepositoryService().deleteDeploymentCascade(deploymentId);
} public static void main(String[] args) {
Test test = new Test();
// test.deploy("hello.jpdl.xml");//流程定义的发布
// test.query();//流程定义的查询
// test.del("10001");//删除流程定义
}
}