摘要:
JBoss jBPM (JAVA Business Process Management) 為開源工作流程引擎, 具有非常高的彈性及可擴展性, 可使用圖形介面事先定義工作流程序述, 提供非同步, 排程, 自動觸發動作等功能
JBoss jBPM (JAVA Business Process Management) 為開源工作流程引擎,
具有非常高的彈性及可擴展性, 可使用圖形介面事先定義工作流程序述,
提供非同步, 排程, 自動觸發動作等功能,
JBoss jBPM 可以與任何的資料庫集成, 並能嵌入於任何的JAVA企業應用系統.
開始備忘記:
[1] 安裝 jdk 5
[2] 安裝 JBoss jBPM server
[3] 安裝 Eclipse WTP
[4] 安裝 JBoss IDE
[5] 建立第一個 jBPM project
[1] 安裝 jdk 5:
下載 jdk-1_5_0_07-nb-5_0-win-ml.exe
http://java.sun.com/j2se/1.5.0/download-netbeans.html
安裝至 D:\jdk1.5.0_07
新增環境變數 JAVA_HOME=D:\jdk1.5.0_07
D:\jdk1.5.0_07\bin 加入至 PATH 中
D:\jdk1.5.0_07\lib\dt.jar 及 D:\jdk1.5.0_07\lib\tools.jar 加入至 CLASSPATH 中
執行 D:\>java -version
輸出 java version "1.5.0_07" 即安裝成功.
[2] 安裝 JBoss jBPM server:
下載 jbpm-starters-kit-3.1.2.zip
http://www.jboss.com/products/jbpm/downloads
http://superb-west.dl.sourceforge.net/sourceforge/jbpm/jbpm-starters-kit-3.1.2.zip
解壓縮至 D:\jboss_jbpm
D:\jboss_jbpm\readme.html 介紹每個目錄的功能.
這裡只需要關心 D:\jboss_jbpm\jbpm-server 目錄, 這是 JBoss jBPM server
執行 D:\jboss_jbpm\jbpm-server\start.bat 啟動 JBoss jBPM server
JBoss jBPM server 已提供了一個 JSF 的 web sale order 的例子.
進入 http://localhost:8080/jbpm/
隨便選一個 user 登入, 就可以測試預設的 web sale order workflow.
如下圖所示
官方的介面使用教學:
http://wiki.jboss.org/wiki/Wiki.jsp?page=JbpmGettingStarted
[3] 安裝 Eclipse WTP:
下載 wtp-all-in-one-sdk-R-1.5.0-200606281455-win32.zip
http://www.eclipse.org/webtools/
http://www.eclipse.org/downloads/download.php?file=/webtools/downloads/drops/R-1.5.0-200606281455/wtp-all-in-one-sdk-R-1.5.0-200606281455-win32.zip
解壓至 D:\eclipse_wtp
[4] 安裝 JBoss IDE:
Eclipse:Help -> Software Updates -> Find and Install -> Search for new features to install
按 New Remote Site
Name: JBOSS IDE
URL: http://download.jboss.org/jbosside/updates/stable
選擇最新的版本然後安裝.
[5] 建立第一個 jBPM project:
Eclipse: File -> New -> Other -> JBoss jBPM -> Process Project
Project Name: First_jBPM -> Next -> Finish
預設會產生一整套測試檔案, 這備忘記就是對這些檔案作簡介.
如果想更深入了解 jBPM , 查看官方的文檔是最好的方法.
檔案結構如下所示
右鍵點選 gpd.xml -> Open With -> Text Editor , 就會出現如下所示代碼
<!---------------------- gpd.xml --------------------->
<?xml version="1.0" encoding="UTF-8"?>
<process-diagram name="simple" width="469" height="438">
<node name="start" x="150" y="25" width="140" height="40">
<transition name="to_state"/>
</node>
<node name="first" x="150" y="125" width="140" height="40">
<transition name="to_end"/>
</node>
<node name="end" x="150" y="225" width="140" height="40"/>
</process-diagram>
<!---------------------- gpd.xml --------------------->
這是 graphical process designer 的描述檔案.
這裡只是簡單描述三個 nodes 的位置: start , first, end
右鍵點選 processdefinition.xml -> Open With -> Text Editor , 就會出現如下所示代碼
<!---------------------- processdefinition.xml --------------------->
<?xml version="1.0" encoding="UTF-8"?>
<process-definition
xmlns="urn:jbpm.org:jpdl-3.1"
name="simple">
<start-state name="start">
<task>
<controller>
<variable name="color" />
<variable name="size" />
</controller>
</task>
<transition name="to_state" to="first">
<action name="action" class="com.sample.action.MessageActionHandler">
<message>Going to the first state!</message>
</action>
</transition>
</start-state>
<state name="first">
<transition name="to_end" to="end">
<action name="action" class="com.sample.action.MessageActionHandler">
<message>About to finish!</message>
</action>
</transition>
</state>
<end-state name="end"></end-state>
</process-definition>
<!---------------------- processdefinition.xml --------------------->
workflow engine 將根據此流程檔運作.
<start-state name="start"> 流程初始點.
<transition name="to_state" to="first">
<action name="action" class="com.sample.action.MessageActionHandler">
<message>Going to the first state!</message>
</action>
</transition>
這裡描述初始點將過渡至 first 點.
而過渡至 first 點時會觸發 com.sample.action.MessageActionHandler [後面會介紹]
並設定此 ActionHandler 的 message 為 "Going to the first state!"
<state name="first">
<transition name="to_end" to="end">
<action name="action" class="com.sample.action.MessageActionHandler">
<message>About to finish!</message>
</action>
</transition>
</state>
這裡描述 first 點. 通過此點將過渡至 end 點.
而過渡至 end 點時會觸發 com.sample.action.MessageActionHandler [後面會介紹]
並設定此 ActionHandler 的 message 為 "About to finish!"
<end-state name="end"> 流程結速點.
右鍵點選 processdefinition.xml -> Open With -> jBPM Graphical Process Designer
然後點 Diagram , 就會出現如下圖所示
可以使用 GPD (Graphical Process Designer) 來繪製 workflow
為了簡化備忘記, 參考以下官方教學文檔
http://docs.jboss.com/jbpm/v3/gpd
package com.sample.action;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;
public class MessageActionHandler implements ActionHandler {
// 這是 Listener, 觸發這個 Action 將執行 execute method
private static final long serialVersionUID = 1L;
String message;
public void execute(ExecutionContext context) throws Exception {
context. getContextInstance_r().setVariable("message", message);
// 這裡將上面觸發的 message 加入到該點的 message property
}
}
package com.sample;
import java.io.FileInputStream;
import junit.framework.TestCase;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
public class SimpleProcessTest extends TestCase {
public void testSimpleProcess() throws Exception {
FileInputStream fis = new FileInputStream("processes/simple/processdefinition.xml");
ProcessDefinition processDefinition = ProcessDefinition.parseXmlInputStream(fis);
// 讀取 processdefinition.xml 的流程定義檔
assertNotNull("Definition should not be null", processDefinition);
// 測試這個檔案並不為 null
ProcessInstance instance = new ProcessInstance(processDefinition);
// 建立處理流程檔實例
assertEquals(
"Instance is in start state",
instance. getRootToken_r(). getNode_r(). getName_r(),
"start");
// 測試現在正處於 start 點
assertNull(
"Message variable should not exist yet",
instance. getContextInstance_r(). getVariable_r("message"));
// 測試 start 點的 message 為 null
instance.signal();
// 呼叫 signal() 表示此點處理完成, 將跳至下一點
// 由於上面設定了 ActionHandler, 將會設定 message 為 "Going to the first state!"
assertEquals(
"Instance is in first state",
instance. getRootToken_r(). getNode_r(). getName_r(),
"first");
// 測試現在正處於 first 點
assertEquals(
"Message variable contains message",
instance. getContextInstance_r(). getVariable_r("message"),
"Going to the first state!");
// 由於已經觸發 MessageActionHandler,
// 測試此點 message property 為 "Going to the first state!"
instance.signal();
// 呼叫 signal() 表示此點處理完成, 將跳至下一點
// 由於上面設定了 ActionHandler, 將會設定 message 為 "About to finish!"
assertEquals(
"Instance is in end state",
instance. getRootToken_r(). getNode_r(). getName_r(),
"end");
// 測試現在正處於 end 點
assertTrue("Instance has ended", instance.hasEnded());
// 測試現在是最後終點
assertEquals(
"Message variable is changed",
instance. getContextInstance_r(). getVariable_r("message"),
"About to finish!");
// 由於已經觸發 MessageActionHandler,
// 測試此點 message property 為 "About to finish!"
}
}
/*------------------
分享到:
相关推荐
jboss jbpm 5.0 最新版jboss jbpm 5.0 最新版jboss jbpm 5.0 最新版jboss jbpm 5.0 最新版jboss jbpm 5.0 最新版jboss jbpm 5.0 最新版jboss jbpm 5.0 最新版
JBoss jBPM 是一个复杂的可扩展的工作流管理系统. JBoss jBPM 有直观的流程语言来表示商业流程图的术语比如,任务,异步通讯的等待状态,定时器,自动操作等等.把这些操作绑在一起,, JBoss jBPM 就有了最强大和易扩展性...
JBoss jBPM 3.0 Workflow and BPM 实践
jboss jbpm下的业务流程管理实例(内有文档非常)jboss jbpm下的业务流程管理实例(内有文档非常)
Business Process Management with JBoss jBPM.pdf Business Process Management with JBoss jBPM.pdf
通过JBPM构建BPM Business Process Management with JBoss jBPM 不错的书
NULL 博文链接:https://hongyegu.iteye.com/blog/765007
Spring与JBoss JBPM工作流集成开发指南
JBoss jBPM 实例说明 struts1.1+spring1.2+hibernate3.0+jbpm3.1.4可以tomcat下运行,可通过图形模式发布工程,配置了在网页显示jbpm流程图的标签文件。
JBOSS jBPM4.3源码(jBPM是公开源代码项目,它使用要遵循 Apache License。)
开源工作流JBPM3.2.2开发环境部署 Ant Eclipse插件安装以及数据库
使用JBoss jBPM实现流程访问和执行的授权
A Java developer's guide to the JBoss Business Process Management framework
JBoss jBPM 3.0 Workflow and BPM 实践 目录 1. 介绍 1.1. 综述 1.2. The JBoss jBPM 新手工具箱 1.3. The JBoss jBPM 流程图形设计器 1.4. The JBoss jBPM 核心组件 1.5. The JBoss jBPM 控制台web应用 ...
JBoss jBPM jPDL中文指南 基本上是学习必读的书
JBoss jBPM 是一个复杂的可扩展的工作流管理系统. JBoss jBPM 有直观的流程语言来表示商业流程图的术语比如,任务,异步通讯的等待状态... <br>JBoss jBPM 可以同任何数据库配置可以部署在任何应用服务器上. <br>
jBoss jBPM是一个灵活、可扩展的流程语言框架。jPDL是建立在这个通用框架只上的流程语言 jPDL有一个具有最小的依赖性和简单易用的java库,能部署在高吞吐量的j2ee集群应用服务器环境