本博文只是简要对JBPM4进行介绍,如需更详细内容请自行google
链接:
JBPM4入门——2.在eclipse中安装绘制jbpm流程图的插件
JBPM4入门——4.封装流程管理的工具类(JbpmUtil)
1.在util包下新建JbpmUtil 工具类
package com.test.util;
import org.jbpm.api.Configuration;
import org.jbpm.api.ExecutionService;
import org.jbpm.api.ProcessEngine;
import org.jbpm.api.RepositoryService;
public class JbpmUtil {
private static ProcessEngine processEngine;
private static RepositoryService repositoryService;
private static ExecutionService executionService;
static{
//流程定义引擎的初始化
processEngine = Configuration.getProcessEngine();
//管理流程定义
repositoryService = processEngine.getRepositoryService();
//executionService 用于执行流程定义实例
executionService = processEngine.getExecutionService();
}
/**
* 获取流程管理的repositoryService
* @return
*/
public static RepositoryService getRepositoryService(){
return repositoryService;
}
/**
* 获取执行流程定义的ExecutionService
* @return
*/
public static ExecutionService getExecutionService(){
return executionService;
}
}
2.在test类里使用工具类来管理流程、并测试发布
package com.test.test;
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 static void main(String[] args) {
Test test = new Test();
test.deploy("hello.jpdl.xml");
}
}
3.查看数据库中的数据:deployment表中多了一条数据

再看发布表中的数据:多了4条数据

本文介绍了JBPM4流程引擎的基础使用方法,包括开发环境搭建、工具类封装及流程定义的发布、查询与删除等操作,并通过示例展示了如何使用JBPM4在Eclipse环境中进行流程管理。
249

被折叠的 条评论
为什么被折叠?



