jBPM5 入门

1. 
jBPM Business Process Management (BPM) 套件: 
     Runtime Engine         引擎 
    Web-based Designer     基于WEB的设计器 Oryx Designer 
    Eclipse Plugin         
    Management Console     管理控制台 
    Miscellaneous          其它如流程仓库Guvnor 

2. 
执行流 
流程描述 - 流程 - 活动 - 事务 

流程实例 
process instance 

3. 
jBPM5 基于BPMN 2.0流程语言 

4. 
安装eclipse jBPM 插件及使用教程 
4.1 
安装需求 
     JDK 1.5+ 
    Ant 1.7+ 
4.2 
下载 jBPM5 安装文件并解压 
http://sourceforge.net/projects/jbpm/files/jBPM%205/jbpm-5.0-Final/  

4.3 
安装Demo 
ant install.demo 

将执行如下任务 
------ 
下载 JBoss AS 
下载 Eclipse 
下载 Drools Guvnor into JBoss AS 
下载 Oryx Designer 
下载 jBPM gwt-console 
下载 jBPM Eclipse plugin 
下载 Drools Eclipse plugin 
4.4 
启动Demo 
ant start.demo 

将执行如下任务 
------ 
启动  H2 database 
启动 JBoss AS 
启动 Eclipse 
启动 Human Task Service 

4.5 
导入例子工程 
http://people.redhat.com/kverlaen/install-eclipse-jbpm.swf  

4.6 
WEB 管理控制台 
http://localhost:8080/jbpm-console  

账号: 
krisv / krisv 

4.7 
流程仓库 
[url]http://localhost:8080/drools-guvnor [/url] 

4.8 
停止Demo 
ant stop.demo 

4.9 官方论坛 
http://community.jboss.org/en/jbpm?view=discussions  


5. 流程对象 

Events 
    Start Event (None, Conditional, Signal, Message, Timer) 
    End Event (None, Terminate, Error, Escalation, Signal, Message, Compensation) 
    Intermediate Catch Event (Signal, Timer, Conditional, Message) 
    Intermediate Throw Event (None, Signal, Escalation, Message, Compensation) 
    Non-interrupting Boundary Event (Escalation, Timer) 
    Interrupting Boundary Event (Escalation, Error, Timer, Compensation) 


Activities 
    Script Task (Java or MVEL expression language) 
    Task 
    Service Task 
    User Task 
    Business Rule Task 
    Manual Task 
    Send Task 
    Receive Task 
    Reusable Sub-Process (Call Activity) 
    Embedded Sub-Process 
    Ad-Hoc Sub-Process 
    Data-Object 

Gateways 
    Diverging 
        Exclusive (Java, MVEL or XPath expression language) 
        Inclusive (Java, MVEL or XPath expression language) 
        Parallel 
        Event-Based 
    Converging 
        Exclusive 
        Parallel 
    Lanes 

Data  
    Java type language 
    Process properties 
    Embedded Sub-Process properties 
    Activity properties 

Connecting objects  
    Sequence flow 


6. 
WS-HT service 
人工任务(非自动化任务) 

生命周期 
1. 
创建 - 准备 - Reserved - 处理 - 完成|失败 
2. 
(准备 - Reserved - 处理) - 挂起 
3. 
(创建 - 准备 - Reserved - 处理) - 错误|退出|忽略 

7. 
流程上下文 
kcontext 
org.drools.runtime.process.ProcessContext 

8. 
Action 

9. 
Node 

10. 
流程变量及作用域 

11. 
约束 
代码约束 
规则约束 

12. 
事件 
流程内部事件 
外部事件 


13. 
定时器 
Timer Event 

14. 
会话:流程实例通过会话与流程引擎交互,会话通过knowledge base的引用查询流程定义.通过会话可以启动流程实例. 

创建knowledge base 
Java代码   收藏代码
  1. KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();  
  2. kbuilder.add(ResourceFactory.newClassPathResource("MyProcess.bpmn"), ResourceType.BPMN2);  
  3. KnowledgeBase kbase = kbuilder.newKnowledgeBase();  


创建Session 

Java代码   收藏代码
  1. StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();  
  2. ProcessInstance processInstance = ksession.startProcess("com.sample.MyProcess");  


添加或移除监听器 

ProcessEventListener 


15. 
整合jBPM 和 MyEclipse8.6 

1. 
下载GEF 
http://www.eclipse.org/downloads/download.php?file=/tools/gef/downloads/drops/3.5.2/R201002241200/GEF-ALL-3.5.2.zip&url=http://download.actuatechina.com/eclipse/tools/gef/downloads/drops/3.5.2/R201002241200/GEF-ALL-3.5.2.zip&mirror_id=385  

2. 
复制步骤4中已经下载的包 
drools 
--------- 
drools-5.2.0.M1-eclipse-all.zip 

jbpm 
--------- 
jbpm-5.0.0-eclipse-all.zip 

3. 解压并安装插件-链接方式 

Drools 
--------- 
E:\bisoft\tools\myeclipse\myplugins\drools520\eclipse 
E:\bisoft\tools\myeclipse\myplugins\drools520\eclipse\features 
E:\bisoft\tools\myeclipse\myplugins\drools520\eclipse\plugins 
E:\bisoft\tools\myeclipse\myplugins\drools520\eclipse\plugins\lib\*.jar 

注意上面的lib目录下的包是安装目录下的lib目录及子目录下的所有JAR包.为了方便,我都放到lib目录下.为什么这样做?因为drools的包依赖这些包,所以必须的. 

jbpm 
------- 
E:\bisoft\tools\myeclipse\myplugins\jbpm5\eclipse\plugins 

gef 
------- 
E:\bisoft\tools\myeclipse\myplugins\gef\eclipse\features 
E:\bisoft\tools\myeclipse\myplugins\gef\eclipse\plugins 

注意这里的GEF不能用前面步骤4的GEF SDK包,因为MyEclipse使用Eclipse3.5,因此要下载3.5对应的GEF SDK包.

链接文件 
------- 
E:\bisoft\tools\myeclipse\dropins\drools520.link 
path=E:\\bisoft\\tools\\myeclipse\\myplugins\\drools520 

E:\bisoft\tools\myeclipse\dropins\gef.link 
path=E:\\bisoft\\tools\\myeclipse\\myplugins\\gef 

E:\bisoft\tools\myeclipse\dropins\jbpm5.link 
path=E:\\bisoft\\tools\\myeclipse\\myplugins\\jbpm5 

4. 配置JBPM运行时 
指向runtime目录 

5. 导入例子 
sample\evaluation 

6. 配置JBOSS_HOME 
指向jboss-5.1.0.GA 

7. 复制build.xml到工程下,并修改 
Xml代码   收藏代码
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2.   
  3. <project name="jBPM5">  
  4.       
  5.   <property name="install.home" value="E:/bisoft/sharelib/jbpm-installer" />  
  6.   <property name="jboss.home" value="E:/bisoft/jboss-5.1.0.GA" />  
  7.   <property name="jboss.bind.address" value="localhost" />  
  8.   
  9.   <!-- ############ START/STOP ############ -->  
  10.   
  11.   <!-- Start H2 server -->  
  12.   <target name="start.h2">  
  13.     <java classname="org.h2.tools.Server" fork="true" spawn="true">  
  14.       <arg value="-tcp" />  
  15.       <classpath location="${install.home}/db/driver/h2.jar" />  
  16.     </java>  
  17.   </target>  
  18.   <!-- Stop H2 server -->  
  19.   <target name="stop.h2">  
  20.     <java classname="org.h2.tools.Server" fork="true">  
  21.       <classpath location="${install.home}/db/driver/h2.jar" />  
  22.       <arg value="-tcpShutdown" />  
  23.       <arg value="tcp://localhost:9092" />  
  24.     </java>  
  25.   </target>  
  26.   
  27.   <!-- Start JBoss AS -->  
  28.   <target name="start.jboss">  
  29.     <property name="jboss.full.path.win" location="${jboss.home}/bin/run.bat" />  
  30.     <exec executable="${jboss.full.path.win}" spawn="on"  
  31.           os="Windows 7,Windows Vista,Windows XP,Windows 2000,Windows 2003">  
  32.       <env key="JAVA_OPTS" value="-XX:MaxPermSize=256m -Xms256m -Xmx512m" />  
  33.       <arg value="-b" />  
  34.       <arg value="${jboss.bind.address}" />  
  35.       <arg value="-Djbpm.console.directory=${install.home}/sample/evaluation/src/main/resources" />  
  36.     </exec>  
  37.     <waitfor maxwait="5" maxwaitunit="minute" checkevery="30"  
  38.              checkeveryunit="second" timeoutproperty="jboss.timeout">  
  39.       <socket server="${jboss.bind.address}" port="8080" />  
  40.     </waitfor>  
  41.     <fail if="jboss.timeout" message="jboss did not start within 5 minutes"/>  
  42.   </target>  
  43.   <!-- Stop JBoss AS -->  
  44.   <target name="stop.jboss">  
  45.     <exec executable="${jboss.home}/bin/shutdown.bat"  
  46.           os="Windows 7,Windows Vista,Windows XP,Windows 2000,Windows 2003">  
  47.       <arg value="-s" />  
  48.       <arg value="jnp://${jboss.bind.address}:1099" />  
  49.       <arg value="-S" />  
  50.     </exec>  
  51.   </target>  
  52.   
  53.   <!-- Start Human Task Service -->  
  54.   <path id="classpath.human.task">  
  55.     <fileset dir="${install.home}/runtime" includes="**/*.jar"/>  
  56.     <fileset dir="${install.home}/db/driver" includes="**/*.jar"/>  
  57.   </path>  
  58.   <target name="start.human.task">  
  59.     <mkdir dir="${install.home}/task-service/target"/>  
  60.     <javac srcdir="${install.home}/task-service/src" destdir="${install.home}/task-service/target" classpathref="classpath.human.task">  
  61.       <compilerarg value="-Xlint:unchecked"/>  
  62.     </javac>  
  63.     <copy todir="${install.home}/task-service/target">  
  64.       <fileset dir="${install.home}/task-service/resources"/>  
  65.     </copy>  
  66.     <java classname="org.jbpm.DemoTaskService" fork="true">    
  67.       <classpath>  
  68.         <pathelement path="${install.home}/task-service/target"/>  
  69.         <path refid="classpath.human.task" />  
  70.       </classpath>  
  71.     </java>  
  72.   </target>  
  73.   
  74.   <!-- Start Demo -->  
  75.   <target name="start.demo" depends="start.h2,start.jboss,start.human.task" />  
  76.   <!-- Stop Demo -->  
  77.   <target name="stop.demo" depends="stop.h2,stop.jboss" />  
  78.   
  79. </project>  


前面的两个属性根据实际情况修改. 

8. 启动H2数据库, JBOSS, 人工服务 
start.demo 


9. 运行或调试ProcessTest 


10. 如果你的BPMN文件没有对应的编辑器,可以运行这个类并将输出的信息复制到 
myeclipse/configuration/org.eclipse.equinox.simpleconfigurator/bundles.info的最后, 然后删除configuration/org.eclipse.update目录并重启MyEclipse. 

Java代码   收藏代码
  1. package com.sample;  
  2.   
  3. import java.io.File;  
  4. import java.util.ArrayList;  
  5. import java.util.List;  
  6.   
  7. @SuppressWarnings("unchecked")  
  8. public class CreatePluginsConfig {  
  9.     public CreatePluginsConfig() {  
  10.     }  
  11.       
  12.     public static void main(String[] args) {  
  13.         // 插件位置  
  14.         String plugin = "E:\\bisoft\\tools\\myeclipse\\myplugins\\drools520";    
  15.         new CreatePluginsConfig().print(plugin);    
  16.     }  
  17.       
  18.       
  19.     public void print(String path) {  
  20.         List list = getFileList(path);  
  21.         if (list == null) {  
  22.             return;  
  23.         }  
  24.   
  25.         int length = list.size();  
  26.         for (int i = 0; i < length; i++) {  
  27.             String result = "";  
  28.             String thePath = getFormatPath(getString(list.get(i)));  
  29.             File file = new File(thePath);  
  30.             if (file.isDirectory()) {  
  31.                 String fileName = file.getName();  
  32.                 if (fileName.indexOf("_") < 0) {  
  33.                     print(thePath);  
  34.                     continue;  
  35.                 }  
  36.                 String[] filenames = fileName.split("_");  
  37.                 String filename1 = filenames[0];  
  38.                 String filename2 = filenames[1];  
  39.                 result = filename1 + "," + filename2 + ",file:/" + path + "\\"  
  40.                         + fileName + "\\,4,false";  
  41.                 System.out.println(result);  
  42.             } else if (file.isFile()) {  
  43.                 String fileName = file.getName();  
  44.                 if (fileName.indexOf("_") < 0) {  
  45.                     continue;  
  46.                 }  
  47.                 int last = fileName.lastIndexOf("_");// 最后一个下划线的位置  
  48.                 String filename1 = fileName.substring(0, last);  
  49.                 String filename2 = fileName.substring(last + 1, fileName  
  50.                         .length() - 4);  
  51.                 result = filename1 + "," + filename2 + ",file:/" + path + "\\"  
  52.                         + fileName + ",4,false";  
  53.                 System.out.println(result);  
  54.             }  
  55.   
  56.         }  
  57.     }  
  58.   
  59.     public List getFileList(String path) {  
  60.         path = getFormatPath(path);  
  61.         path = path + "/";  
  62.         File filePath = new File(path);  
  63.         if (!filePath.isDirectory()) {  
  64.             return null;  
  65.         }  
  66.         String[] filelist = filePath.list();  
  67.         List filelistFilter = new ArrayList();  
  68.   
  69.         for (int i = 0; i < filelist.length; i++) {  
  70.             String tempfilename = getFormatPath(path + filelist[i]);  
  71.             filelistFilter.add(tempfilename);  
  72.         }  
  73.         return filelistFilter;  
  74.     }  
  75.   
  76.     public String getString(Object object) {  
  77.         if (object == null) {  
  78.             return "";  
  79.         }  
  80.         return String.valueOf(object);  
  81.     }  
  82.   
  83.     public String getFormatPath(String path) {  
  84.         path = path.replaceAll("\\\\", "/");  
  85.         path = path.replaceAll("//""/");  
  86.         return path;  
  87.     }  
  88. }  


11. 
结果 




12. 
stop.demo 

这里有个缺陷, 没有停止人工服务. 因此必须到任务管理器去结束进程. 

13. 
完成. 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
目录 第一章 概述 1 1.1 什么是jBPM? 1 1.2 概览 2 1.3 核心引擎 3 1.4 Eclipse编辑器 4 1.5 基于Web的设计器 5 1.6 jBPM控制台 5 1.7 文档结构 6 第二章 获得开始 7 2.1 下载 7 2.2 获得开始 7 2.3 社区 8 2.4 资源 8 2.41许可证 8 2.42 源代码 9 2.4.3 从源文件构建 9 第三章 安装 9 3.1 必备的 9 3.2 下载 installer 9 3.3 演示安装 10 3.4 10分钟指南: 使用Eclipse工具 10 3.5 10分钟向导:使用jBPM控制台 12 3.6 10分钟指南:使用Guvnor知识库和设计器 13 3.7 如果遇到问题或有问题应该怎么去做 14 3.7 经常被问的问题 14 第四章:核心引擎的API 15 4.1 jBPM API 16 4.11 Knowledge Base 17 4.12 会话 17 4.13 事件 19 4.2. Knowledge-based API 21 第五章 核心引擎:基础 21 5.1 创建一个流程 21 5.1.1 Eclipse BPMN2.0图形编辑器插件 22 5.1.2 使用XML定义流程 22 5.1.3使用流程API定义流程 24 5.2 不同流程构造的细节概述 25 5.3 流程属性的细节 26 5.4 事件细节 26 5.4.1 开始事件 26 5.4.2 结束事件 27 5.4.3 中间事件 28 5.5 动作细节 29 5.5.1 脚本任务 29 5.5.3 服务任务 30 5.5.3 用户任务 31 5.5.4 重用的子流程 32 5.5.5 业务规则任务 32 5.5.6 嵌入子流程 33 5.5.7 多个实例子流程 33 5.6 Gateways 细节 34 5.6.2 合并网关 35 5.7 在你的应用中使用流程 35 5.8 其他特性 36 5.8.1 数据 36 5.8.2 约束 37 5.8.3 动作脚本 38 5.8.4 事件 39 5.8.5 计时器 40 5.8.6 更新流程 41 第六章 BPMN 2.0 核心引擎 43 6.1 Business Process Model and Notation(BPMN)2.0 Specification业务流程建模和符号2.0规范 43 6.2 例子 47 6.3 支持的元素/属性 48 第七章 核心引擎:持久化和事务 54 7.1 运行时状态 54 7.1.1 二进制持久化 54 7.1.2 Safe Pionts 54 7.1.3 配置持久化 55 7.1.4 事务 58 7.2 流程定义 58 7.3 历史日志 59 7.3.1 将流程事件存储到数据库 59 第八章 核心引擎:示例 60 8.1 jBPM示例 60 8.2 示例 61 8.3 单元测试 61 第九章 Eclipse BPMN 2.0 Plugin 62 9.1 安装 62 9.2 创建你的BPMN 2.0 流程 62 9.3 元素和属性的顾虑 65 第十章 设计器 66 10.1 安装 67 第十一章 控制台 68 11.1 安装 68 11.2 运行流程管理控制台 68 11.2.1 管理流程实例 69 11.2.2 人工任务列表 71 11.2.3 报告 72 11.3 添加新的流程/任务表 73 11.4 REST interface 74 第十二章 Human Tasks 75 12.1 流程内的Human tasks 75 12.1.1 Swimlanes 78 12.2 Human task 管理组件 78 12.2.1 任务生命周期 78 12.2.2 将任务组件链接到jBPM引擎 79 12.2.3 启动任务管理组件 81 12.2.4 和任务管理组件的交互 83 12.3 人工任务管理接口 84 12.3.1 Eclipse integration 84 12.3.2 基于Web的任务视图 84 第十三章 特定领域的流程 84 13.1 介绍 84 13.2 示例:通告 85 13.2.1 创建工作定义 86 13.2.2 注册你的工作定义 86 13.2.3 在你的流程中使用你最新的工作条目 87 13.2.4 执行服务节点 89 第十四章 测试和调试 91 14.1 单元测试 91 14.1.1 使用Helper方法创建你的session 92 14.1.2 断言 92 14.1.3测试与外部服务的结合 93 14.1.4 配置持久化 94 14.2 调试 94 14.2.1 流程实例视图 95 14.2.2 人工任务视图 96 14.2.3 核查视图 96 第十五章 流程知识库 97 第十六章 业务活动监视器 99 16.1 报告 99 16.2 直接接入 101 第十七章 复杂流程 102 第十八章 和Maven,OSGi,Spring的整合 105 18.1 Maven 105 18.2 OGSi 107

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值