??xml version="1.0" encoding="utf-8" standalone="yes"?> jBPM is an embeddable BPM engine, which means that you can take jBPM and embed it into your own java project, rather then installing a separate product and integrate with it. One of the key aspects that make this possible is minimizing the dependencies. This chapter discusses the jbpm libraries and their dependencies. jBPM是一个嵌入式?span lang="EN">BPMQ业务程序管理)引擎。本章讨?span lang="EN">jbpm库和它的依赖库?span lang="EN"> jBPM 3 requires J2SE jbpm-[version].jar is the library with the core jbpm functionality.?span lang="EN">jbpm的核心功能库?span lang="EN"> jbpm-identity-[version].jar is the (optional) library containing an identity component as described in Section 11.11, “The identity component?/font>. 可选的Q这个库包含了n份验证组件。用于流E的参与者的理?span lang="EN"> In a minimal deployment, you can create and run processes with jBPM by putting only the commons-logging and dom4j library in your classpath. Beware that persisting processes to a database is not supported. The dom4j library can be removed if you don't use the process xml parsing, but instead build your object graph programatically. 最的jbpm部vQ只需要核?span lang="EN">jbpm库和commons-logging库,以及dom4j库到你的classpath中。此Ӟ不支持持久化业务E序到数据库?span lang="EN"> Library?/span> Usage用?/span> Description描述 Directory目录 commons-logging.jar logging in jbpm and hibernate The jBPM code logs to commons logging. The commons logging library can be configured to dispatch the logs to e.g. java 1.4 logging, log4j, ... See the apache commons user guide for more information on how to configure commons logging. if you're used to log4j, the easiest way is to put the log4j lib and a log4j.properties in the classpath. commons logging will automatically detect this and use that configuration. lib/jboss (from jboss dom4j- process definitions and hibernate persistence xml parsing lib/dom4j A typical deployment for jBPM will include persistent storage of process definitions and process executions. In that case, jBPM does not have any dependencies outside hibernate and its dependent libraries. 典型?span lang="EN">jBPM部v包括持久化业务程序定义和执行的功能?需?span lang="EN">Hibernate Of course, hibernate's required libraries depend on the environment and what features you use. For details refer to the hibernate documentation. The next table gives an indication for a plain standalone POJO development environment. 下面的表l出了简单的标准POJO部v环境需要的W三方库?span lang="EN"> jBPM is distributed with hibernate 3.1 final. But it can also work with 3.0.x. In that case, you might have to update a few hibernate queries in the hibernate.queries.hbm.xml configuration file. For more info about customizing queries, see Section 7.6, “Customizing queries?/font> Library?/span> Usage Description Directory hibernate3.jar hibernate persistence the best O/R mapper lib/hibernate (hibernate 3.1 final) antlr- used in query parsing by hibernate persistence parser library lib/jboss (from jboss cglib-2.1_2jboss.jar hibernate persistence reflection library used for hibernate proxies lib/jboss (from jboss commons-collections.jar hibernate persistence lib/jboss (from jboss ehcache-1.1.jar hibernate persistence (in the default configuration) second level cache implementation.二~存实现?/span> When configuring a different cache provider for hibernate, this library is not required. lib/hibernate jaxen-1.1-beta-4.jar process definitions and hibernate persistence XPath library (used by dom4j) lib/hibernate jdbc2_0-stdext.jar hibernate persistence lib/hibernate asm.jar hibernate persistence asm byte code library 二进制代码修改库 lib/hibernate asm-attrs.jar hibernate persistence asm byte code library lib/hibernate The beanshell library is optional. If you don't include it, you won't be able to use the beanshell integration in the jbpm process language and you you'll get a log message saying that jbpm couldn't load the Script class and hence, the script element won't be available. Beanshell库是可选的?span lang="EN"> Library Usage Description Directory bsh- beanshell script interpreter Only used in the script's and decision's. When you don't use these process elements, the beanshell lib can be removed, but then you have to comment out the Script.hbm.xml mapping line in the hibernate.cfg.xml lib/jboss Chapter 2. Getting startedh This chapter takes you through the first steps of getting JBoss jBPM and provides the initial pointers to get up and running in no time. 初始?span lang="EN">JBpm3.12 Listed below are the different jBPM packages that are available today. Each of these packages contains one or more downloadable files. Along with each of these files goes a description of its contents and a pointer to any relevant installation instructions if they are available. All downloads described below can be found on the sourceforge jbpm downloads page. Download JBoss jBPM 3 at sourceforge.net. This is the main distribution package containing the core engine and a number of additional modules that you may need to work with jBPM. 包括JBpm核心和其他包?span lang="EN"> 包含了包括图形化设计器在内的所有模块,能够帮助你快速启动?/span> 核心Q包括核心引擎和w䆾l徏Q内有用h南文档?/span> jBPMq程设计?span lang="EN"> Download JBoss jBPM Process Designer at sourceforge.net. The designer is an eclipse plugin and enables you to author 创作your process definitionsq程定义 and to easily deploy them. The plug-in is available for download either as a zipped Eclipse feature or as a zipped Eclipse update site. There is no difference in content, the only difference is in the way you have to do the installation. 使用本地站点更新方式部v?/span> q个是手工部|Ӏ?/span> Download JBoss jBPM BPEL extension at sourceforge.net. It contains only one file : jbpm-bpel-<version>.zip. To get started with the BPEL extensions, look in the User's Guide in the 'doc' subfolder of the toplevel folder. jbpm-bpelQ含?/span>JBoss jBPM?/span>BPEL扩展件方面的信息?/span> BPEL是一个规范的SOAlg。因ZJBoss jBPM使用的许可证不同Q所以被独立了出来?/span> 2.2. The JBoss jBPM project directory Alternatively, you can get JBoss jBPM from cvs with the following information: To get cvs developer access, you must sign contributors agreement and you need an ssh key. More information on both can be found on the JBoss cvs repository wiki page5.1. Java runtime environment
5.2. jBPM libraries
5.3. Third party librariesW三方库
]]>
]]>
]]>
]]>
1. 程的定?/font>
没有采用WfMC提出的流E定义语aXPDLQ而是自己开发了一U称?span lang="EN-US">JPDL的语a来定义流E。因此,在开发一个应用时我们最l需要生成一个符合该XML schema的文?span lang="EN-US">processdefinition.xml来表C定义好的流E。它可以manually获得Q也可以使用可视化的定义工具自动生成?span lang="EN-US">
专门提供了一个开发流E的环境Q称?span lang="EN-US">process development environment(pde)。可?/span>
?/span>
jbpm
根目录下执行命o
ant create.pde
来生?/span>
pde
工作目录
Build.xml
?/span>
工具解析
文gQƈ运行流E时所需的相关信息存储到数据库中?/span>
Lib
存放了开发和配置程所需的全部库文gQ包括数据库?/span>
驱动?/span>
Src
包括开发和配置程的全部源文g和所需资源?/span>
Src/config
jbpm.properties
?/span>
log4j.properties
。其中,
jbpm.propertie
文g包含了数据库的配|信息。因此,更换数据库或数据库的
jdbc
驱动都需要修改这里?/span>
Scr/java
存放
java
源文件?/span>
Src/process
存放工作定义文?/span>
(processdefinition.xml)
和相关的资源文gQ如囄?/span>
form
文g?/span>
Src/test
存放试代码?/span>
Target/classes
?/span>
src/java
中源码的输出目录Q存攄译后?/span>
class
文g?/span>
Target/par
存放用命?/span>
ant build.process.archives
生成?/span>
par
包?/span>
Par
包实际上是?/span>
src/process
中的程定义及相x件打包成
zip
形式存储?/span>
Target/test-classes
存放试E序的编译结果?/span>
Target/test-report
存放试报告?/span>
2. 程的执?/font>
把负责执行流E的cd打包?span lang="EN-US">jbpm.core.jarQ它也是JBPM工作引擎的核心。在开发一个工作流应用Ӟ只需该jar文g攑ֈ相应?span lang="EN-US">lib目录下面。而开发h员就可以专注于开发一个流E模型,完成ҎE的定义Q而无需q多考虑程执行的细节?span lang="EN-US">
3. 程的客L
servlet containerQ我们这里选择?span lang="EN-US">tomcat?span lang="EN-US">JBPM开发一?span lang="EN-US">webapp所需的类打包?span lang="EN-US">jbpm.web.jarQ包括自定义?span lang="EN-US">tag?span lang="EN-US">Struts用到的类{等。开发应用时Q将?span lang="EN-US">jar攑ֈWEB-INF\lib下面可以了?span lang="EN-US">
webapp应用的开发和普?span lang="EN-US">webapp的开发方式很怼。包l构也保持一贯作风:
所以,我们需要做的主要工作是完成客户端应用所需?/span>
jsp
面的开发,可以选用
Struts
来进行开发。需要注意的是,我们要对
lib
目录下的
jbpm.properties
文gq行配置Q主要是Ҏ据库
jdbc
驱动的配|?/span>
4. pȝ数据库的创徏
可以支持多种数据库系l,包括MSSQL,Q?span lang="EN-US">MysqlQ?span lang="EN-US">OracleQ?span lang="EN-US">hdbsql{。它提供了很灉|的配|方式,只需要修?span lang="EN-US">jbpm.properties文gQ同时将相应?span lang="EN-US">JDBC Driver拯?span lang="EN-US">lib目录可以了。利?span lang="EN-US">ant?span lang="EN-US">generate.ddl命oQ?span lang="EN-US">JBPMq支持自动生成用于创建系l表?span lang="EN-US">sql脚本Q而且可以生成对应于各U数据库pȝ的脚本,非常便于数据库系l的更换和系l数据库的创建?span lang="EN-US">
5. 开发过E?/font>
5.0.27
request a payraiseZQ见下图Q,介绍一下利?span lang="EN-US">JBPM开发一个工作流应用需要完成的工作?/span>
1) processdefinition.xmlQ还要对程执行时用到的其他资源进行定义。比如,?span lang="EN-US">web应用中用到的囄Q?span lang="EN-US">form{。还需要配|?span lang="EN-US">form.xmlQ该文g定了流E中不同状态和form的关p,?span lang="EN-US">request a payraise状态下Q需要如下图所C的formQ?/span>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE process-definition PUBLIC "-//jBpm/jBpm Mapping DTD 2.0//EN" "http://jbpm.org/dtd/processdefinition-2.0.dtd">
<process-definition name="pay raise process">
<!-- SWIMLANES -->
<swimlane name="requester" />
<swimlane name="boss">
<delegation class="org.jbpm.delegation.assignment.ActorAssignmentHandler">cg</delegation>
</swimlane>
<swimlane name="erp operator">
<delegation class="org.jbpm.delegation.assignment.ActorAssignmentHandler">pf</delegation>
</swimlane>
<!-- START-STATE -->
<start-state name="request a payraise" swimlane="requester">
<transition to="evaluating"/>
</start-state>
<!-- NODES -->
<state name="evaluating">
<assignment swimlane="boss" />
<transition name="approve" to="fork"/>
<transition name="disapprove" to="done"/>
</state>
<fork name="fork">
<transition to="updating erp asynchronously" />
<transition to="treating collegues on cake and pie" />
</fork>
<state name="updating erp asynchronously">
<assignment swimlane="erp operator" />
<transition to="join" />
</state>
<state name="treating collegues on cake and pie">
<assignment swimlane="requester" />
<transition to="join" />
</state>
<join name="join">
<transition to="done" />
</join>
<!-- END-STATE -->
<end-state name="done" />
</process-definition>
2)
processdefinition.xml文gQ我们就可以配置程。即使用ant命oQ解析这个文件ƈ且将执行旉要的信息存储在数据库中。如下图Q?br />
3)
jbpm.core.jar好?span lang="EN-US">
4)
我们需要做的主要工作是完成客户端应用所需?/span>
jsp
面的开发。包括登录页面,查看自己?/span>
tasklist
面Q执?/span>
task
的页面等。除此之外,q可以通过日志来完成流E的监控和管理界面。这些都由应用的需求来军_?/span>
目录 W一?/span>l论 JBoss jBPM 是一个灵zȝQ易扩展的工作流理pȝ?/span>JBoss jBPM有一套直观的程建模语言Q这套语a能用dQ?/span>taskQ,异步通信的等待状态(wait state Q,定时器(timerQ,自动化的动作Q?/span>automated actionQ等来图形化的表CZ务流E。ؓ了把q些操作集成在一 PJBoss jBPM拥有强大的,易扩展的控制程机制?/span> JBoss jBPM对外依赖E度很小Q你完全可以像用java的类库一L它。ƈ且它也可以被部v在高性能?/span>J2EE集群应用服务器上?/span> JBoss jBPM能配|在M数据库上Qƈ且能被部|在M的应用服务器上?/span> 1.1 总览 工作和业务程处理功能的核心部分被打包成一个简单的javacd。这个类库包括了q样一个服务:程信息的存储,更新Q和从数据库中重新取回?/span> ?/span>1.1Q?/span>JBoss jBPMl成模块的概略图 1.2 JBoss jBPM starter kit starter kit是一个包?/span>jbpm所有模块的下蝲包。这个下载包中包括以下模块: · jbpm-server, 一个预选配|好?span lang="EN">jboss应用服务器?span lang="EN">
]]>
· jbpm-designer, 囑Ş化定制流E的eclipse插g?span lang="EN">
· jbpm-db, jBPM的数据库兼容?span lang="EN"> (见后边论q?span lang="EN">)?span lang="EN">
· jbpm, jbpm的核心模块,其中包括libs文g夹和q个用户说明?span lang="EN">
· jbpm-bpel, JBoss jBPM?span lang="EN">BPEL扩展的一些参考资?span lang="EN">
预先配置好的JBoss应用服务器具有如下组成部分:
jBPM核心模块Q被打包成一个用于提供服务的存档文g
带有jbpm表的集成数据?/span>Q默认的hypersonic数据库拥?/span>jbpm表,q且q个表已l拥有一个流E了?/span>
Jbpm?/span>web控制?/span>Q它既可以被Jbpm理员用也可以被程的参与者用?/span>
执行定时器的Jbpm的调度程序,q个调度E序?/span>starter kit里边被配|成一?/span>servlet。这?/span>servlet会生一个新的线E来监视和执行定时器?/span>
一个具体流E的例子Q它已经被部|在jbpm数据库中了?/span>
1.3 JBoss jBPM 程囑Ş定制?/span>
JBoss jBPMq拥有一套图形化的设计工兗这个设计器是一个图形化的业务流E定制工兗?/span>
JBoss jBPM程囑Ş定制器是eclipse的一个插件。单独安装这个定制器非常单?/span>
q个囑Ş设计器最重要的特性是Q业务分析h员也能像技术开发h员一L它来完成d。这使得业务程建模能^滑的转换到具体技术实现?/span>
q个插g可以利用eclipse的一般升U机刉过一个升U站点得到安装(zip文g格式Q。也可以通过解压一个特定的包到eclipse的安装目录来安装此插件?/span>
1.4 JBoss jBPM的核心模?/span>
JBoss jBPM的核心模块是一个用来管理流E定义和程实例的执行环境的普?/span>javaE序?/span>
JBoss jBPM是一?/span>javacd。所以它可以被用在Q?/span>java环境中,比如Q?/span>web应用E序Q?/span>swing应用E序Q?/span>EJBQ?/span>web service……?/span>JBPMcdq可以被打包q被当成无状态会?/span>EJBQ?/span>stateless session EJBQ用。这样可使它被部|在集群上ƈ且适应高性能应用。这些无状态会?/span>EJB必须W合J2EE1.3规范q样才能使它可以被部|在M应用服务器上?/span>
JBoss jBPM的核心模块被打包成一个简单的java库文件。依你功能的需要,jbpm-3.0.jarq个库文件对一些第三方的类库比?/span>hibernate, dom4j有所依赖。这些依赖在W五章(部vQ中作了详细的说明?/span>
至于持久化,JBPM在内部用?/span>hibernate。除了传l的O/R映射功能Q?/span>hibernateq解决了不同数据SQL dialect差异的问题,q?/span>JBPM能适应现在所有的数据库?/span>
JBoss jBPM API可以被你工程中Q何的java代码调用Q比如,你的web应用E序Q?/span>EJBQ?/span>web service 模块Q消息驱?/span>bean或其它Q?/span>java模块?/span>
1.5 JBoss jBPM web应用E序的控制台
jBPM web应用E序的控制台提供两种服务。首先,它被用来当作一个用来和程执行q程中生的dq行交互的主要用h口,其次Q它q是一个用来检查和操作q行实例的管理和监控q_?/span>
1.6 JBoss jBPM人员l织模块
JBoss jBPM可以和Q何包括h员和其他l织信息的公司结构集成在一赗但是对那些l织l构信息模块很难获取的项目,JBoss jBPM提供了这个模块。这个模块用的模型要比传统?/span>servlet, ejb,portlet模型丰富的多?/span>
更多信息Q请参照W九章第九节人员l织模块
1.7 JBoss jBPM调度E序
JBoss jBPM调度E序是一个用来监和执行在流E执行过E中讄的定时器的模块?/span>
定时器模块被打包?/span>jbpm的核心包中,但是它必被部v在以下环境中Q或者你必须订制一个调?/span>servletQ它来生一个监线E,或者你必须启动一个单独的JVM来执行调度程序?/span>
1.8 JBoss jBPM 数据库兼容包
JBoss jBPM 数据库兼容包是一个下载包Q它包括所有的资料Q?/span>drivers?/span>scripts,用这些你可以?/span>jbpmq行在你选择的数据库上?/span>
1.9 JBoss jBPM BPE的扩?/span>
JBoss jBPM BPE的扩展是一个ؓ了支?/span>BPEL独立的扩展包?/span>BPEL的本质就是一l用来参照别?/span>web service?/span>web service?/span>xml脚本语言?/span>