本博文只是简要对JBPM4进行介绍,如需更详细内容请自行google
链接:
JBPM入门系列文章:
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条数据