The starter kit is a download that contains all the jBPM components bundled in one easy download. The download includes:
jBPM 需要数据库支持Q?/span> jBPM ?x)把自己的一个初始化数据存储到数据库Q同时工作流的数据也是存储到数据库中的?/span> jBPM 使用 Hibernate 来做q存储层,因此只要?/span> Hibernate 支持的数据库Q?/span> jBPM 也就支持?/span>
本文先以 MySQL ZQ然后再?/span> Oracle ZQ来谈谈 jBPM 的数据库初始化操作?/span>
注:(x)在上面的 JBoss 自带的示例中Qƈ没有讄数据库,那是因ؓ(f) jBPM 默认使用的是内存数据?/span> hsqldb ?/span>
1 、首先安?/span> MySQL ?/span>
MySQL 的安装比较简单,|上也有很多文章Q本文不再赘q。本指南所?/span> MySQL 版本?/span> MySQL 4.1 Q?/span> for windows Q。再找一?/span> MySQL 客户端,目的是方便查看数据库中的数据Q本文推荐?/span> MySQL |站上免Ҏ(gu)供的“ MySQL Query Brower ”Q当然你用其他的客户端也行,比如 MySQL-Front ?/span>
2 、徏?/span>
MySQL 中创Z个库Q库名:(x) jbpm
3 、生成徏表的 SQL 语句q徏?/span>
?/span>
jbpm-starters-kit-
D:\jbpm-starters-kit-
D:\jbpm-starters-kit-
?/span>
DOS
H下Q进?/span>
D:\jbpm-starters-kit-
ant mysql.scripts
执行成功后,?/span>
D:\jbpm-starters-kit-
先安装好 Oracle 服务器。我们公司有现存?/span> Oracle 服务器,也提供给了我一个属于我自己的用户名Q一d可以Q意在我的库之下创了。所以这一步就省了Q没有的自个先装好吧?/span>
讉K Oracle 推荐?#8220; PLSQL Developer ”。不q要q接 Oracle q要在本Z装上 Oracle 自己的客L(fng)E序Q里面提供了 JDBC 包和一些配|。要q接服务器还得配|一下,我一般都是不?/span> GUI 而直接改 tnsnames.ora 文gQ在我的?sh)脑里此文g的目录地址是:(x) D:\oracle\ora92\network\ADMIN\tnsnames.ora Q内容如?/span> ( 两面有两个配|了 ) Q?/span>
# TNSNAMES.ORA Network Configuration File: E:\oracle\ora92\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.
WXXRDB_192.168.3.2 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.3.2)(PORT = 1521))
)
(CONNECT_DATA =
(SID = wxxrDB)
(SERVER = DEDICATED)
)
)
WXXRDB_192.168.4.2 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.4.2)(PORT = 1521))
)
(CONNECT_DATA =
(SID = wxxrDB)
(SERVER = DEDICATED)
)
)
前面都是 Oracle 的一些知识,不会(x)?/span> Google 一下吧。最后配|好后,?/span> PLSQL Developer 输入你的用户名和密码联接?/span> Oracle Q就?/span> OK 了?/span>
参考上?/span> MySQL 的步骤,基本一P(x)
Q?Q?span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> ?/span> jbpm 改名?/span> jbpm.3
Q?Q?span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> 再执?/span> ant oracle.scripts
Q?Q?span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">
?/span>
jbpm-db\build\oracle\scripts
目录?/span>
oracle.create.sql
脚本Q在
Oracle
中生?/span>
jBPM
的所有表。在“
PLSQL Developer
”中可以新Z?/span>
Command Windows
H口然后输入命o(h)Q?/span>
@D:\jbpm-starters-kit-
工作虽然还在不成熟的发展阶D,甚至q没有一个公认的规范标准。但其应用却已经在快速展开Q这说明市场对工作流框架的需求是急迫而巨大的?/span>
jBPM 的正处在不断发展中,做ؓ(f)开源Y件的特点Q其设计变化往往很大。所以一些过ȝ资料可能已经不适用了。于是作者根据自q使用l验Q重新整理出q䆾文档Q以备学?fn)参考?/span>
注:(x)本文使用?/span> jBPM 版本?/span> 3.1.1
所?/span> JAVA 开发第一个需要安装的Q没什么好说的。记得把pȝ变量 JAVA_HOME 设上?/span>
Ant 是?/span> jBPM 必须的一个工兗?/span> jBPM 中的很多操作都要用到 Ant ?/span>
安装Ҏ(gu)Q?/span>
Q?/span> 1 Q先下蝲Q?/span> http://archive.apache.org/dist/ant/binaries/ Q选一个如Q?/span> apache-ant-1.6.5-bin.zip ?/span>
Q?/span> 2 Q解压到 D:\ant Q当然其他目录也可以Q?/span>
Q?/span> 3 Q设|如下系l变量:(x) ANT_HOME=d:\ant ?/span>
Q?/span> 4 Q把 %ANT_HOME%\bin 加入到系l变?/span> PATH 中?/span>
Eclipse 不是开?/span> jBPM 必须的工P但它是对 jBPM 开发很有帮助的工具Q特别是 jBPM 提供了一?/span> Eclipse 插g用来辅助开?/span> jBPM 。关?/span> Eclipse 的安装不赘述了,本文用的版本是:(x) Eclipse3.2
jBPM 的下载地址Q?/span> http://www.jboss.com/products/jbpm/downloads
l JBoss jBPM ?/span> jBPM 的Y件包
l JBoss jBPM Starters Kit 是一个综合包Q它包括?/span> jBPM 软g包、开发插件、一个配|好了的Z JBoss ?/span> jBPM CZ、一些数据库配置文gCZ?/span>
l JBoss jBPM Process Designer Plugin 是辅助开?/span> jBPM ?/span> Eclipse 插g?/span>
l JBoss jBPM BPEL Extension jBPM 关于 BPEL 的扩展包
本指南选择下蝲Q?/span> JBoss jBPM Starters Kit 。下载后解压?/span> D:\jbpm-starters-kit-3.1 Q目录下含有五个子目录:(x)
l jbpm jBPM 的Y件包
l jbpm-bpel 只含有一个网?/span>
l jbpm-db 各种数据?/span> hibernate 配置文gCZQ有些还包含了相应的 jdbc 驱动E序?/span>
l jbpm-designer 辅助开?/span> jBPM ?/span> Eclipse 插gQ具体在 jbpm-gpd-feature 子目录中
l jbpm-server 一个已l配|好了的Z JBoss ?/span> jBPM CZ .
前面我们说了Q在 JBoss jBPM Starters Kit ?/span> jbpm-server 目录是一个已l配|好的了 jBPM CZQ那么让我们来感觉一?/span> jBPM 做出的东西吧?/span>
双击 jbpm-server 目录下的 start.bat 文gQ启?/span> JBoss 服务。这时会(x)打开一?/span> DOS H口Q启动完成后Q日志会(x)不断输出Q其中最后一句是“ 13:55:39,937 DEBUG [StaticNotifier] going to wait for (CMD_EXECUTOR, java.lang.Object@1df59bd) ”Q这表示 jBPM 在开始工作了Q它不断q行轮询?/span>
打开|页Q?/span> http://localhost:8080/jbpm/ 得到如下画面
q是一个已l用 jBPM 开发好的用户定单流E,h下单、审核、估L(fng)程。它所用的数据库是一个内|的数据库?/span>
?/span> cookie monster 用户dQ选择“ create new web sale order ”可以创徏一个定单。如下图所C,在图左边是填写的定单情况Q右边一整个定货程的示意图Q红色框表示程q行到哪一步了。填写好定单好,选择“ Save and Close Task ”Q完成定单提交?/span>
选择右上角的“ Login as another user ”以另外一个用户名 ernie d。这时可以看?/span> ernie 用户的Q务列表中多了一V?/span>
点进dQ显C如下画面。这个示例对中文的支持不好,全都昄成了 unicode 码了。不这什么多Q反正知道是q么回事p了。在 comment 填写意见,?/span> OK 按钮Q进入到下一步。如果选择 more info needed 按钮Q则打回l?/span> cookie monster 用户修改定单?/span>
下面的流E,q里׃再赘qC。在q个很标准的工作示例中Q我们基本可以看?/span> jBPM 的应用范围还是比较广的。而且从这个示例,我们是看不出?/span> jBPM 的,也就是说 jBPM 在后台v着作用?/span>
从这个例子,q看不出 jBPM 的优ѝ不q,如果在一个流E不定Q经帔R要变动的目中, jBPM 的好处将?x)显然出来。应?/span> jBPM 后,改变?gu)程只需改变?gu)程描述文gQ这在后面的内Ҏ(gu)到?/span>
q是一个已做好的示例,接下来我们将仉K这个实例来开发一个请假流E?/span>
The main responsibility of a WFMS is to maintain the state of process executions. The state model of jBpm is based on a graph with nodes and transitions. Nodes and transitions are the main ingredients of a process definition. A state is an example of a node.
The 2 most important interactions with jBpm are : starting one instance (=one execution) of a process definition and signalling the end of a state. As a result of both these interactions jBpm will calculate the next state of the process instance.
The state graph, provides the structure of the process. Actions are pieces of programming logic that can be executed upon events in the process. There are three types of events : entering a node, leaving a node and taking a transition. While jBpm is calculating the next state, a number of these events will fire.
The main file in a process archive is processdefinition.xml
. That file
contains the formal description of the process. The act of parsing the processdefinition.xml
and storing it in the database is called deploying a process. All other files
in a process archive are stored as attachments with the process definition (either
in the database or as files on the filesystem).
jBpm store its process definitions in the database. So deploying a process into jbpm actually means parsing the processdefinition.xml and store it in the jbpm database. This can be done in one of 2 ways:
par
and deploypar
.
par
lets you create a process archive from a set of
files. deploypar
deploys a process archive to the
database. The deploypar takes a jbpm.properties file as an
attribute. That file specifies the jbpm configurations including
the database to which the process archive has to be deployed. For
more information about the properties, see
configuration.
After packing and deploying this process to the jBpm database,
the next code example shows how to start a process instance.
When the process instances was started, jBpm calculated that the next state is 'evaluating' and that user CarlGauss is responsible for this task. This resulted in the token of the process being assigned to 'CarlGauss'. The next snippet asks jBpm all the tokens that are waiting for CarlGauss. In this example we assume that the first task is the one we started above. When CarlGauss has made his decision, he informs jBpm by means of the endOfState method call. Note that in this example we explicitly provide the name of the leaving transition to indicate the choice made by the user.
code to signal an end of state