jbpm4.3 eclipse下 hellworld
http://blog.163.com/sir_876/blog/static/1170522320101164433422/
1.下载JBPM4.3
http://sourceforge.net/projects/jbpm/files/
下载后解压,你将看到有以下的子目录
* install:安装jbmp所需配置文件
* doc: 用户手册,javadoc和开发指南
* examples: 用户手册中用到的示例流程
* lib: 第三方库和一些特定的jBPM依赖库
* src: 源代码
* jbpm.jar: jBPM主库归档
*migration:貌似是低版本迁移文件,没用上还
2.下载jdk(标准java5或更高版本)
3.在eclipse官网下载最新版本的eclipse
4.在eclipse上安装GPD插件
步骤如下
* Help-->Install New Software
* 点击Add
* 在Add Site 对话框里点击Archive....
* 在JBPM4.0 HOME中找到install\src\gpd\jbpm-gpd-site.zip 并点击 '打开'
* 选择出现的 jPDL 4 GPD 更新站点
* 点击 下一步.. 然后点击 完成
* 接受协议..
* 当它询问的时候重启eclipse
注意:安装过程会很慢,一定要耐心的等待。
5.新建一个java项目,加入jbpm4的依赖包。
*JBPM4_HOME/jbpm.jar
*JBPM4_HOME/lib/*.jar
6.在项目的src目录下点击右键-->New-->JBPM 4 Process Definetion,在弹出的对话框的File Name 中填写hello,该文件是以jpdl.xml为后缀结尾的,然后点击Finish。
7.在hello.jpdl.xml中绘制一个简单的流程图,包含一个start活动,一个state活动和一个end活动,然后用转移(transition)将他们链接起来.
<?xml version="1.0" encoding="UTF-8"?> <process name="hello" xmlns="http://jbpm.org/4.0/jpdl"> <start name="start1" g="247,64,48,48"> <transition name="to state1" to="state1" g="-59,-17"/> </start> <state name="state1" g="254,167,92,52"> <transition name="to end1" to="end1" g="-47,-17"/> </state> <end name="end1" g="244,277,48,48"/> </process> <?xml version="1.0" encoding="UTF-8"?><process name="hello" xmlns="http://jbpm.org/4.0/jpdl"> <start name="start1" g="247,64,48,48"> <transition name="to state1" to="state1" g="-59,-17"/> </start> <state name="state1" g="254,167,92,52"> <transition name="to end1" to="end1" g="-47,-17"/> </state> <end name="end1" g="244,277,48,48"/></process>
package com;import junit.framework.TestCase;import org.jbpm.api.Configuration;import org.jbpm.api.ExecutionService;import org.jbpm.api.ProcessEngine;import org.jbpm.api.ProcessInstance;import org.jbpm.api.RepositoryService;public class HelloTest extends TestCase { ProcessEngine processEngine = null; String deployId = null; //主要是用来发布流程 RepositoryService repositoryService = null; //主要用来启动流程,执行流程 ExecutionService executionService = null; protected void setUp() { processEngine = new Configuration().buildProcessEngine(); repositoryService = processEngine.getRepositoryService(); executionService = processEngine.getExecutionService(); //将定义的流程配置文件部署到数据库中 deployId = repositoryService.createDeployment().addResourceFromClasspath("hello.jpdl.xml").deploy(); } protected void tearDown() { repositoryService.deleteDeploymentCascade(deployId); } public void testEndHelloWorld() { //启动流程实例 ProcessInstance processInstance = executionService.startProcessInstanceByKey("hello"); //启动流程后我们的流程会自动进入到state1活动,并处在等待状态 assertTrue(processInstance.isActive("state1")); String pid = processInstance.getId(); //让state1活动继续往下执行,并进入结束活动,流程结束 processInstance = executionService.signalExecutionById(pid); assertTrue(processInstance.isEnded()); } }