﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-　　　　　　　　　　　　　礼物 ^_^ -文章分类-JBPM4</title><link>http://www.blogjava.net/libin2722/category/40764.html</link><description>虚其心，可解天下之问；专其心，可治天下之学；静其心，可悟天下之理；恒其心，可成天下之业。</description><language>zh-cn</language><lastBuildDate>Tue, 14 Jul 2009 17:03:01 GMT</lastBuildDate><pubDate>Tue, 14 Jul 2009 17:03:01 GMT</pubDate><ttl>60</ttl><item><title>jBPM 4.0 解读分析</title><link>http://www.blogjava.net/libin2722/articles/286675.html</link><dc:creator>礼物</dc:creator><author>礼物</author><pubDate>Tue, 14 Jul 2009 05:15:00 GMT</pubDate><guid>http://www.blogjava.net/libin2722/articles/286675.html</guid><wfw:comment>http://www.blogjava.net/libin2722/comments/286675.html</wfw:comment><comments>http://www.blogjava.net/libin2722/articles/286675.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/libin2722/comments/commentRss/286675.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/libin2722/services/trackbacks/286675.html</trackback:ping><description><![CDATA[
		<div class="article" lang="en-US">
				<div class="titlepage">
						<div>
								<div>
										<h1 class="title">
												<a id="d0e1">jBPM 4.0 解读分析</a>
										</h1>
								</div>
								<div>
										<div xmlns="" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="authorgroup">
												<div class="authors">
														<a id="d0e1">by <span xmlns="http://www.w3.org/1999/xhtml" class="firstname">Jeff Yu</span><span xmlns="http://www.w3.org/1999/xhtml" class="othername">(余昌)</span></a>
												</div>
												<div>
														<div class="revhistory">
																<table summary="Revision history" border="1" width="100%">
																		<tbody>
																				<tr>
																						<th colspan="2" align="left" valign="top">
																								<b>Revision History</b>
																						</th>
																				</tr>
																				<tr>
																						<td align="left">Revision 0.1</td>
																						<td align="left">2009/06/29</td>
																				</tr>
																				<tr>
																						<td colspan="2" align="left">增加了前3章的内容</td>
																				</tr>
																		</tbody>
																</table>
														</div>
												</div>
										</div>
										<hr />
								</div>
								<div class="toc">
										<dl>
												<dt>
														<span class="section">
																<a href="http://people.apache.org/%7Ejeffyu/articles/zh_CN/jbpm/#configuration">1. jBPM 配置文件 (IOC)</a>
														</span>
												</dt>
												<dt>
														<span class="section">
																<a href="http://people.apache.org/%7Ejeffyu/articles/zh_CN/jbpm/#pvm.architecture">2. jBPM PVM 架构</a>
														</span>
												</dt>
												<dd>
														<dl>
																<dt>
																		<span class="section">
																				<a href="http://people.apache.org/%7Ejeffyu/articles/zh_CN/jbpm/#d0e133">2.1. Environment</a>
																		</span>
																</dt>
																<dt>
																		<span class="section">
																				<a href="http://people.apache.org/%7Ejeffyu/articles/zh_CN/jbpm/#d0e156">2.2. Service</a>
																		</span>
																</dt>
																<dt>
																		<span class="section">
																				<a href="http://people.apache.org/%7Ejeffyu/articles/zh_CN/jbpm/#d0e170">2.3. Command and Command Service</a>
																		</span>
																</dt>
																<dt>
																		<span class="section">
																				<a href="http://people.apache.org/%7Ejeffyu/articles/zh_CN/jbpm/#d0e213">2.4. PVM Models: ProcessDefinition, ActivityBehaviour, Transition, Event</a>
																		</span>
																</dt>
																<dt>
																		<span class="section">
																				<a href="http://people.apache.org/%7Ejeffyu/articles/zh_CN/jbpm/#d0e269">2.5. API整体架构图</a>
																		</span>
																</dt>
														</dl>
												</dd>
												<dt>
														<span class="section">
																<a href="http://people.apache.org/%7Ejeffyu/articles/zh_CN/jbpm/#pvm.model">3. jBPM PVM Model(模型)解析</a>
														</span>
												</dt>
												<dd>
														<dl>
																<dt>
																		<span class="section">
																				<a href="http://people.apache.org/%7Ejeffyu/articles/zh_CN/jbpm/#d0e282">3.1. ActivityBehaviour(内部节点)</a>
																		</span>
																</dt>
																<dt>
																		<span class="section">
																				<a href="http://people.apache.org/%7Ejeffyu/articles/zh_CN/jbpm/#d0e327">3.2. ExternalActivityBehaviour(外部节点)</a>
																		</span>
																</dt>
																<dt>
																		<span class="section">
																				<a href="http://people.apache.org/%7Ejeffyu/articles/zh_CN/jbpm/#d0e358">3.3. 基本流程的实现</a>
																		</span>
																</dt>
																<dt>
																		<span class="section">
																				<a href="http://people.apache.org/%7Ejeffyu/articles/zh_CN/jbpm/#d0e403">3.4. 事件机制 (Event and EventListener)</a>
																		</span>
																</dt>
														</dl>
												</dd>
												<dt>
														<span class="bibliography">
																<a href="http://people.apache.org/%7Ejeffyu/articles/zh_CN/jbpm/#d0e439">Bibliography</a>
														</span>
												</dt>
										</dl>
								</div>
								<div class="abstract">
										<p class="title">
												<b>Abstract</b>
										</p>
		这篇文章主要是介绍了jBPM 4.0的基础架构,以及通过一个简单的例子来让大家知道怎么应用jBPM.
		为什么选择4.0版本呢?以后的主流版本应该是4.0版本的,所以直接写4.0版本的了.
	</div>
								<div class="section" lang="en-US">
										<div class="titlepage">
												<div>
														<div>
																<h2 class="title">
																		<a id="configuration">1. jBPM 配置文件 (IOC)</a>
																</h2>
														</div>
												</div>
										</div>
										<div class="abstract">
												<p class="title">
														<a id="configuration">
																<b>Abstract</b>
														</a>
												</p>
												<a id="configuration">		配置文件是jBPM里面很关键的一步,同时Configuration API可以看做是jBPM里的一个入口API,因为其他很多重要的Service,都是通过这个API,然后生成的,于是我们需要先看一下这个模块.
	</a>
										</div>
										<p>
												<a id="configuration">		在默认情况下,jBPM包里有个jbpm.cfg.xml,这个就是他的配置文件,我们先看下它的内容.
	 </a>
										</p>
										<pre class="programlisting">
												<a id="configuration">
														<br /> &lt;jbpm-configuration&gt;<br />  &lt;import resource="jbpm.default.cfg.xml" /&gt;<br />  &lt;import resource="jbpm.tx.jta.cfg.xml" /&gt;<br />  &lt;import resource="jbpm.jpdl.cfg.xml" /&gt;<br />  &lt;import resource="jbpm.identity.cfg.xml" /&gt;	<br />  &lt;import resource="jbpm.jobexecutor.cfg.xml" /&gt;	<br />&lt;/jbpm-configuration&gt;<br /><br /></a>
										</pre>
										<p>
												<a id="configuration">	 
	 这里,我们再继续看下<span class="emphasis"><em>jbpm.default.cfg.xml</em></span>,看下配置文件到底是长啥样.
	 </a>
										</p>
										<pre class="programlisting">
												<a id="configuration">
														<br />  &lt;process-engine-context&gt; <br />    &lt;repository-service /&gt;<br />    &lt;repository-cache /&gt;<br />    &lt;execution-service /&gt;<br />    &lt;history-service /&gt;<br />    &lt;management-service /&gt;<br />    &lt;identity-service /&gt;<br />    &lt;task-service /&gt;<br />    &lt;hibernate-configuration&gt;<br />      &lt;cfg resource="jbpm.hibernate.cfg.xml" /&gt;     <br />    &lt;/hibernate-configuration&gt;<br />	...........<br />  &lt;/process-engine-context&gt;<br /><br />  &lt;transaction-context&gt;<br />    &lt;repository-session /&gt;<br />    &lt;db-session /&gt;   <br />    &lt;message-session /&gt;<br />    &lt;timer-session /&gt;<br />    &lt;history-session /&gt;<br />    &lt;mail-session&gt;<br />      &lt;mail-server&gt;<br />        &lt;session-properties resource="jbpm.mail.properties" /&gt;<br />      &lt;/mail-server&gt;<br />    &lt;/mail-session&gt;<br />  &lt;/transaction-context&gt;<br /><br /></a>
										</pre>
										<p>
												<a id="configuration">	 
  这个配置文件主要包含了"process-engine-context'和 'transaction-context'的配置.	 
	</a>
										</p>
										<p>
												<a id="configuration">我们知道,现在都是讲究Dependency Inject (Inversion of Control),那么,我们这里到底是哪个类来实现repository-service呢?那配置mail-session又是怎么实例化的呢?
我们先来看下jBPM的IOC实现机制.  
	</a>
										</p>
										<p>
												<a id="configuration">首先是<span class="emphasis"><em>Context</em></span>接口,你可以从这里存储,获得对象.它的接口很简单. 
    
	 </a>
										</p>
										<pre class="programlisting">
												<a id="configuration">  Object get(String key);<br />  &lt;T&gt; T get(Class&lt;T&gt; type);<br /><br />  Object set(String key, Object value);<br /></a>
										</pre>
										<p>
												<a id="configuration">你看可以从Context中获取到组件,对于IOC容器来说，一般情况下都会提供一种加载的方式，比如从xml文件进行加载、从资源文件进行加载。
    </a>
										</p>
										<p>
												<a id="configuration">	
Jbpm4是通过<span class="emphasis"><em>WireParser</em></span>来解析xml,然后创建并把对象存放在<span class="emphasis"><em>WireContext</em></span>. WireContext这个类负责存放,提取对象,内部用一个Map来存储已经创建的对象实例,可以简单得把他看成是IOC的一个实现类.
从<span class="emphasis"><em>WireContext</em></span>的javadoc,我们可以看出,他主要是跟<span class="emphasis"><em>WireDefinition</em></span>, <span class="emphasis"><em>Descriptor</em></span>打
交道. WireContext里面
包含了一个WireDefinition,而WireDefinition里面包含了一系列的Descriptor.每个Descriptor负责创建和
初始化该对象. 比如我们可以看到IntegerDescriptor, FloatDescriptor, ObjectDescriptor等等.
我们来看下Descriptor的接口: </a>
										</p>
										<pre class="programlisting">
												<a id="configuration">
														<br />  /**<br />   * constructs the object.<br />   * @param wireContext {@link WireContext} in which the object is created. This is also the {@link WireContext} <br />   * where the object will search for other object that may be needed during the initialization phase.<br />   * @return the constructed object.<br />   */<br />  Object construct(WireContext wireContext);<br /><br />  /**<br />   *called by the WireContext to initialize the specified object.<br />   */<br />  void initialize(Object object, WireContext wireContext);<br /></a>
										</pre>
										<p>
												<a id="configuration">	 
Descriptor对象的创建可以直接通过Java对象的实例化,比如(new IntegerDescriptor(..)),也可以通过xml的配置文件来实现.可以说我们更经常用xml来配置,所以就有了<span class="emphasis"><em>Binding</em></span>的概念.
Binding类最主要的任务就是把XML DOM 到Java对象的转换. <span class="emphasis"><em>Bindings</em></span>是把Binding归类了一下而已.

以下是Binding的接口.
	 </a>
										</p>
										<pre class="programlisting">
												<a id="configuration">
														<br />public interface Binding { <br />  String getCategory();<br /><br />  /** does this binding apply to the given element? */<br />  boolean matches(Element element);<br /><br />  /** translates the given element into a domain model java object.<br />   * Use the parse to report problems. <br />   */<br />  Object parse(Element element, Parse parse, Parser parser);<br />}<br /></a>
										</pre>
										<p>
												<a id="configuration">如果想看实现,我们可以看下IdentityServiceBinding, RepositoryServiceBinding等等.这里注意下,在jBPM的实现当中,WireDescriptorBinding是根据tagName来解析的.

所以,从jBPM的xml配置文件,到ProcessEngine对象的构建,是这样的一个流程.
</a>
										</p>
										<pre class="programlisting">
												<a id="configuration"> jbpm.cfg.xml –&gt;  jBPMConfigurationParser -&gt;  Binding –&gt;  Descriptor --&gt; WireContext</a>
										</pre>
										<p>
												<a id="configuration">或者更清楚的,我们可以看下下面这张图<sup>[</sup></a>
												<sup>
														<a id="d0e88" href="http://people.apache.org/%7Ejeffyu/articles/zh_CN/jbpm/#ftn.d0e88">1</a>]</sup>.
 <img src="http://people.apache.org/%7Ejeffyu/articles/zh_CN/jbpm/images/ioc.png" /></p>
										<p>
我们不妨也看下ConfigurationTest测试.
	 </p>
										<pre class="programlisting">
												<br />  public void testConfigurationServices() {<br />    ProcessEngine processEngine = new Configuration()<br />        .setXmlString(<br />            "&lt;jbpm-configuration&gt;" +<br />            "  &lt;process-engine-context&gt;" +<br />            "    &lt;repository-service /&gt;" +<br />            "    &lt;execution-service /&gt;" +<br />            "    &lt;management-service /&gt;" +<br />            "  &lt;/process-engine-context&gt;" +<br />            "&lt;/jbpm-configuration&gt;"<br />        )<br />        .buildProcessEngine();<br />    assertNotNull(processEngine);<br />    assertNotNull(processEngine.getExecutionService());<br />    assertNotNull(processEngine.getManagementService());<br />  }<br /></pre>
										<p>
												<span class="emphasis">
														<em>Configuration</em>
												</span>类是jBPM的入口,你可以从
Configuration类中创建ProcessEngine,而从ProcessEngine中获取到RepositoryService,
ExecutionService, TaskService等等.
Configuration类里有两个实现类,一个是JbpmConfiguration,这是默认的jBPM自带的Configuration解析器,
另外一个是SpringConfiguration,这个是jBPM和Spring的集成.
在这里,我们就只看下JbpmConfiguration的实现,在JbpmConfiguration类里,我们可以看到他是这么去调用Parser来
解析xml的. </p>
										<pre class="programlisting">
												<br /> protected void parse(StreamInput streamSource) {<br />   isConfigured = true;<br />   JbpmConfigurationParser.getInstance()<br />     .createParse()<br />     .pushObject(this)<br />     .setStreamSource(streamSource)<br />     .execute()<br />     .checkErrors("jbpm configuration " + streamSource);<br /> }<br /></pre>
										<p>
										</p>
										<p>
在这里,我们可以看到,jbpm的配置文件是有两个元素组成的,一个是process-engine-context,另外一个是transaction-context. 其中process-engine-context里面的元素是包括了对外发布的服务,
比如repository-service, execution-service等等. 而transaction-context则包括了他的内部真正实现,比如repository-service对应repository-session.
也可以简单的把repository-servie看做是API, repository-session看做是SPI. 这样做的好处是,SPI的实现,对API一点影响都没有,很大程度上提供了一个容易集成的特性.
  </p>
										<p>
说到这里,应该对jBPM的IOC介绍的差不多了.我自己在用JBoss IDM project<sup>[<a id="d0e112" href="http://people.apache.org/%7Ejeffyu/articles/zh_CN/jbpm/#ftn.d0e112">2</a>]</sup>来实现jBPM的Identity module时.需要增加如下的配置.
	 </p>
										<pre class="programlisting">
												<br />&lt;jbpm-configuration&gt;<br />  &lt;process-engine-context&gt;<br />    &lt;jboss-idm-identity-session-factory jndi="java:/IdentitySessionFactory" /&gt;<br />  &lt;/process-engine-context&gt;<br />  &lt;transaction-context&gt;<br />    &lt;jboss-idm-identity-session realm="realm://JBossIdentity" /&gt;<br />  &lt;/transaction-context&gt;<br />&lt;/jbpm-configuration&gt;<br /></pre>
										<p>
于是,我需要增加以下的类来完成对象的创建和实例化. <span class="emphasis"><em>JbossIdmIdentitySessionFactoryBinding,JbossIdmIdentitySessionFactoryDescriptor,JbossIdmIdentitySessionBinding,
JbossIdmIdentitySessionDescriptor</em></span>
然后,在<span class="emphasis"><em>jbpm.wire.bindings.xml</em></span>里面注册我们新加的Binding.
从上面我们所说的,不难看出本身这个IOC的实现机制也是很简单的,而且也很容易扩展,如果说到时候和Spring, JBoss MC等IOC容器的集成也是很方便的. 
   </p>
								</div>
								<div class="section" lang="en-US">
										<div class="titlepage">
												<div>
														<div>
																<h2 class="title">
																		<a id="pvm.architecture">2. jBPM PVM 架构</a>
																</h2>
														</div>
												</div>
										</div>
										<p>
												<a id="pvm.architecture">		这里,我们看下jBPM-PVM概念和架构,这也是jBPM整个项目的核心所在.
	</a>
										</p>
										<p>
												<a id="pvm.architecture">	  PVM (Process Virtual Machine), 主要是想作为一个开发平台,在这个平台上,可以很方便的开发工作流,服务编制(orchestration),BPM等等.就比如
	   说jPDL这套语法的内部实现就是基于PVM的.将来基于PVM可以开发一个符合WS-BPEL 2.0的模块. PVM可以简单的看成是一个状态机.
	  我们接下去看下jBPM里面的几个重要概念.
	</a>
										</p>
										<div class="section" lang="en-US">
												<div class="titlepage">
														<div>
																<div>
																		<h3 class="title">
																				<a id="d0e133">2.1. Environment</a>
																		</h3>
																</div>
														</div>
												</div>
												<p>
														<a id="d0e133">
																<span class="emphasis">
																		<em>Environment</em>
																</span>的概念,主要有以下的作用.
	</a>
												</p>
												<div xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="orderedlist">
														<ol>
																<li>
																		<a id="d0e133">使process能在不同的环境下之行,比如可以在标准的Java, 企业级Java,Seam 或者 Spring 环境下运行.</a>
																</li>
																<li>
																		<a id="d0e133">他可以存放着不同的context对象,比如我们之前所看到的配置文件中的process-engine的Context, transaction的Context等.</a>
																</li>
														</ol>
												</div>
												<p>
														<a id="d0e133">   	在代码中,我们想获得其他的组件时,或者变量时,我们总是使用Environment的API, 我们可以看下它的API的几个重要方法.
   	
   	</a>
												</p>
												<pre class="programlisting">
														<a id="d0e133">   	  public abstract &lt;T&gt; T get(Class&lt;T&gt; type); <br />	  /** searches an object based on type.  The search doesn take superclasses of the context elements <br />	   * into account.<br />	   * @return the first object of the given type or null in case no such element was found.  <br />	   */<br />	  public abstract &lt;T&gt; T get(Class&lt;T&gt; type, String[] searchOrder);<br /></a>
												</pre>
												<p>
														<a id="d0e133">
																<span class="emphasis">
																		<em>Environment</em>
																</span>内部是使用Map来保存不同的Context对象, Environment对象的创建主要是有<span class="emphasis"><em>EnvironmentFactory</em></span>来负责.
   	Environment是被保存在ThreadLocal中,如果有多个Environment,那么是选择把Environment(s)放在一个堆栈中,然后再存放在ThreadLocal里.
   	</a>
												</p>
										</div>
										<div class="section" lang="en-US">
												<div class="titlepage">
														<div>
																<div>
																		<h3 class="title">
																				<a id="d0e156">2.2. Service</a>
																		</h3>
																</div>
														</div>
												</div>
												<p>
														<a id="d0e156">Service就是PVM对外发布的服务,包括RepositoryService(比如部署jpdl文件),ExecutionService(负责管理执行),TaskService,ManagementService等等.可以说这是给用户
调用的API.比如我们看下他们的一些方法.

RepositoryService接口的一些方法:

	</a>
												</p>
												<pre class="programlisting">
														<a id="RepositoryService">public interface RepositoryService {<br />  NewDeployment createDeployment();<br />  ProcessDefinitionQuery createProcessDefinitionQuery();<br />  ...<br />}<br /></a>
												</pre>
												<p>
														<a id="RepositoryService">ExecutionService的一些方法:

	</a>
												</p>
												<pre class="programlisting">
														<a id="ExecutionService">public interface ExecutionService {<br />  ProcessInstance startProcessInstanceById(String processDefinitionId);<br />  ProcessInstance signalExecutionById(String executionId); <br />  ...<br />}<br /></a>
												</pre>
												<p>
														<a id="ExecutionService">ManagementService的接口:	
	</a>
												</p>
												<pre class="programlisting">
														<a id="ManagementService">public interface ManagementService {<br />  void executeJob(long jobDbid);<br />  JobQuery createJobQuery();<br />}<br /></a>
												</pre>
												<p>
														<a id="ManagementService">
														</a>
												</p>
										</div>
										<div class="section" lang="en-US">
												<div class="titlepage">
														<div>
																<div>
																		<h3 class="title">
																				<a id="d0e170">2.3. Command and Command Service</a>
																		</h3>
																</div>
														</div>
												</div>
												<p>
														<span class="emphasis">
																<a id="d0e170">
																		<em>Command</em>
																</a>
														</span>
														<a id="d0e170">概念的引入,主要是想对所有的操作做一个封装. 可以说上面每个Service的方法的实现都是通过实现一个Command来操作,然后通过CommandService调用到后面具体的实现.
我们先来看下Command的接口.
	</a>
												</p>
												<pre class="programlisting">
														<a id="d0e170">public interface Command&lt;T&gt; extends Serializable {<br />  T execute(Environment environment) throws Exception;<br />}<br /></a>
												</pre>
												<p>
														<a id="d0e170">很简单,很典型的Command模式.
	</a>
												</p>
												<p>
														<a id="d0e170">我们接下来看<span class="emphasis"><em>CommandService</em></span>接口,顾名思义,他主要是负责来执行Command(s)的操作.所以其他Service的实现都是通过CommandService来调用到后面的实现,可以把CommandService
看做一个桥梁的作用.看一下CommandService的接口.
	</a>
												</p>
												<pre class="programlisting">
														<a id="CommandService">public interface CommandService {<br />  /**<br />   * @throws JbpmException if command throws an exception.<br />   */<br />  &lt;T&gt; T execute(Command&lt;T&gt; command);<br />}	<br /></a>
												</pre>
												<p>
														<span class="emphasis">
																<a id="CommandService">
																		<em>CommandService</em>
																</a>
														</span>
														<a id="CommandService">还有一个特性,就是可以配置Interceptor,比如事务就是在这一Service中来配置.看下CommandService的配置.

	</a>
												</p>
												<pre class="programlisting">
														<a id="CommandServiceConfiguration">    &lt;command-service&gt;<br />      &lt;retry-interceptor /&gt;<br />      &lt;environment-interceptor /&gt;<br />      &lt;standard-transaction-interceptor /&gt;<br />    &lt;/command-service&gt;	<br /></a>
												</pre>
												<p>
														<a id="CommandServiceConfiguration">这里,在执行真正的CommandServiceImpl之前,会先之前retry-Interceptor,environment-interceptor等等.这里的Interceptor的顺序是跟配置的顺序一致的.
比如这样的配置,那就是retry-interceptor在environment-interceptor之前执行.
我们看下面这个图.
    <img src="http://people.apache.org/%7Ejeffyu/articles/zh_CN/jbpm/images/interceptors.png" /></a>
												</p>
												<div xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="tip">
														<h2>
																<a id="CommandServiceConfiguration">Tip</a>
														</h2>
														<a id="CommandServiceConfiguration">     可以说CommandService是最适合处理横截面(cross-cutting)的问题,比如事务,安全等的. CommandService默认下是DefaultCommandService,如果是在使用ejb的情况下,
    它的实现类就是EjbLocalCommandService和EjbRemoteCommandService类. 所以,这里是远程调用,还是本地调用,对用户而言,都是透明的.
      </a>
														<p>
																<a id="CommandServiceConfiguration">
																</a>
														</p>
														<div class="orderedlist">
																<ol>
																		<li>
																				<a id="CommandServiceConfiguration">retry-interceptor的主要作用当碰到StaleObjectException(也就是optimistic locking失败)时,过一定的时间后再尝试.</a>
																		</li>
																		<li>
																				<a id="CommandServiceConfiguration">environment-interceptor的主要作用就是,保证command是在Environment范围内执行,也就是在执行command之前,openEnvironment,执行之后,closeEnvironment.</a>
																		</li>
																		<li>
																				<a id="CommandServiceConfiguration">standard-transaction-interceptor的主要作用就是处理事务.</a>
																		</li>
																		<li>
																				<a id="CommandServiceConfiguration">authorization-interceptor,主要是处理权限校验.</a>
																		</li>
																</ol>
														</div>
														<p>
																<a id="CommandServiceConfiguration">
																</a>
														</p>
												</div>
												<p>
														<a id="CommandServiceConfiguration">
														</a>
												</p>
										</div>
										<div class="section" lang="en-US">
												<div class="titlepage">
														<div>
																<div>
																		<h3 class="title">
																				<a id="d0e213">2.4. PVM Models: ProcessDefinition, ActivityBehaviour, Transition, Event</a>
																		</h3>
																</div>
														</div>
												</div>
												<p>
														<a id="d0e213">ProcessDefinition是一个定义好的工作流程. OpenProcessDefinition里面包含了启始的Activity. 流程的走向是通过Activity的流向来组成的.
Transition就是用来连接Activity而后来构成一个流程的.
一个工作流的工作引擎,最基本的两个功能:一个是设计好当前的工作流程.第二个是有个东西需要来体现当前走到流程的哪一步,那么PVM中的Execution API就是这个作用.
至于最后一个Event,就是你可以定义一些事件,比如当流程进入到某一个Activity的时候,促发email. Event和Activity最大的区别在于Event本身不会构成对流程走向的改变.
   	</a>
												</p>
												<p>
														<a id="d0e213">我们先看下ActivityBehaviour的接口.
	</a>
												</p>
												<pre class="programlisting">
														<a id="ActivityBehaviour">public interface ActivityBehaviour extends Serializable {<br />  void execute(ActivityExecution execution) throws Exception;<br />}	<br /></a>
												</pre>
												<p>
														<a id="ActivityBehaviour">就是到这个Activity,需要执行的操作都在execute方法里. 还有一种ActivityBehaviour,就是属于wait state,也就是会停留在这个节点上,
需要外部的一些触发,才会继续执行下去,这种情况,需要实现的接口就是<span class="emphasis"><em>ExternalActivityBehaviour</em></span>, 接口如下.
 </a>
												</p>
												<pre class="programlisting">
														<a id="ExternalActivityBehaviour">public interface ExternalActivityBehaviour extends ActivityBehaviour { <br />  //handles an external trigger.  <br />  void signal(ActivityExecution execution, String signalName, Map&lt;String, ?&gt; parameters) throws Exception;<br />}<br /></a>
												</pre>
												<p>
														<a id="ExternalActivityBehaviour"> 
 
Wait State (也就是实现ExternalActivityBehaviour)的促发,是通过Transition来完成的,来看下Transition这个接口.
	</a>
												</p>
												<pre class="programlisting">
														<a id="Transition">public interface Transition extends ObservableElement {<br />  /** the activity from which this transition leaves. */<br />  Activity getSource();<br /><br />  /** the activity in which this transition arrives. */ <br />  Activity getDestination();<br />}<br /></a>
												</pre>
												<p>
														<a id="Transition">在pvm中,也包括了对event的支持,event的接口如下.
	</a>
												</p>
												<pre class="programlisting">
														<a id="Transition">public interface EventListener extends Serializable { <br />  void notify(EventListenerExecution execution) throws Exception;<br />}<br /></a>
												</pre>
												<p>
														<a id="Transition">如我们之前所说的, <span class="emphasis"><em>ProcessDefinition</em></span>是由Activity,Transition以及Event组成的,ProcessDefinition是由<span class="emphasis"><em>ProcessDefinitionBuilder</em></span>
的API来创建.我们稍微看下这个API的使用.
	</a>
												</p>
												<pre class="programlisting">
														<a id="ProcessDefinitionBuilder">		ClientProcessDefinition definition = ProcessDefinitionBuilder.startProcess("jeffProcess")<br />											 .startActivity("initial", new AutomaticActivity())<br />											 .initial()<br />											 .transition("first")<br />											 .endActivity()<br />											 .startActivity("first", new WaitStateActivity())<br />											 .transition("end", "endSignal")<br />											 .endActivity()<br />											 .startActivity("end", new AutomaticActivity())<br />											 .endActivity()<br />											 .endProcess();<br /></a>
												</pre>
												<p>
														<a id="ProcessDefinitionBuilder">
														</a>
												</p>
												<div xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="tip">
														<h2>
																<a id="ProcessDefinitionBuilder">Tip</a>
														</h2>
														<p>
																<a id="ProcessDefinitionBuilder">这里,我们注意到返回的是<span class="emphasis"><em>ClientProcessDefinition</em></span>,那么他和<span class="emphasis"><em>ProcessDefinition</em></span>的区别在哪儿呢?
<span class="emphasis"><em>ClientProcessDefinition</em></span>是继承<span class="emphasis"><em>ProcessDefinition</em></span>,他还包括了一些负责创建和启动<span class="emphasis"><em>ProcessInstance</em></span>的方法.
类似的,你会发现有<span class="emphasis"><em>ClientProcessInstance</em></span>和<span class="emphasis"><em>ProcessInstance</em></span>接口,他们的区别也是ClientProcessInstance多了负责启动的start方法.
	</a>
														</p>
												</div>
												<p>
														<a id="ProcessDefinitionBuilder">
														</a>
												</p>
										</div>
										<div class="section" lang="en-US">
												<div class="titlepage">
														<div>
																<div>
																		<h3 class="title">
																				<a id="d0e269">2.5. API整体架构图</a>
																		</h3>
																</div>
														</div>
												</div>
												<p>
														<a id="d0e269">      我们最后从整体上来看下这些API之间的联系,我觉得Developer Guide上的这个图片很清楚的描述了他的架构思路.
     <img src="http://people.apache.org/%7Ejeffyu/articles/zh_CN/jbpm/images/apis.png" />
	 
这里需要注意的是,本身PVM内部的流程定义模型是POJO的,所以如果你只是想测试流程的正确性,你只需要直接使用Client的API,比如ClientProcessDefinition, ClientProcessInstance等的API.
不需要去调用RepositoryService, ProcessEngineService. 这些Service是针对你把ProcessDefinition在保存在数据库的情况下才需要用的.
	 
    </a>
												</p>
										</div>
								</div>
								<div class="section" lang="en-US">
										<div class="titlepage">
												<div>
														<div>
																<h2 class="title">
																		<a id="pvm.model">3. jBPM PVM Model(模型)解析</a>
																</h2>
														</div>
												</div>
										</div>
										<p>
												<a id="pvm.model">这里,我们将利用PVM所提供的Model,来实现一个基本的工作流引擎.
	</a>
										</p>
										<div class="section" lang="en-US">
												<div class="titlepage">
														<div>
																<div>
																		<h3 class="title">
																				<a id="d0e282">3.1. ActivityBehaviour(内部节点)</a>
																		</h3>
																</div>
														</div>
												</div>
												<p>
														<a id="d0e282">正如我们之前所说的,<span class="emphasis"><em>ActivityBehaviour</em></span>是整个流程的定义核心所在,我们再看下它的API.
</a>
												</p>
												<pre class="programlisting">
														<a id="d0e282">public interface ActivityBehaviour extends Serializable {    <br />  void execute(ActivityExecution execution) throws Exception;<br />}<br /></a>
												</pre>
												<p>
														<a id="d0e282">当之行到ActivityBehaviour的时候,整个流程的走向完全是由他的execute()方法来决定. 比如你可以调用execution.end()来结束这个流程,或者调用execution.waitForSignal()进入一个等待状态.

我们接下去来实现一个很简单的ActivityBehaviour.
</a>
												</p>
												<pre class="programlisting">
														<a id="d0e282">public class Display implements ActivityBehaviour {<br />  String message;<br /><br />  public Display(String message) {<br />    this.message = message;<br />  }<br /><br />  public void execute(ActivityExecution execution) {<br />    System.out.println(message);<br />  }	  <br />}<br /></a>
												</pre>
												<p>
												</p>
												<div xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="tip">
														<h2>
																<a id="d0e282">隐式(implicit)的execute方法执行顺序</a>
														</h2>
														<a id="d0e282">如果我们在execute()方法中,没有显示的调用execution中的方法,比如waitForSignal(),take(transition)等方法,那么默认的顺序是这样的.
</a>
														<div class="orderedlist">
																<ol>
																		<li>
																				<a id="d0e282">如果当前的节点有默认的outgoing transition,那么就调用这个默认的transition.</a>
																		</li>
																		<li>
																				<a id="d0e282">如果当前的节点有父节点,那么就调用到父节点.</a>
																		</li>
																		<li>
																				<a id="d0e282">最后,如果都没有,那就调用execution.end()方法.</a>
																		</li>
																</ol>
														</div>
												</div>
												<p>
														<a id="d0e282">我们先用这个Display,来创建下面的process.
    </a>
												</p>
												<div class="figure">
														<div class="figure-contents">
																<div class="mediaobject" align="center">
																		<a id="activity.example">
																				<img src="http://people.apache.org/%7Ejeffyu/articles/zh_CN/jbpm/images/process.ab.png" alt="Display example process" align="middle" />
																		</a>
																</div>
														</div>
														<p class="title">
																<a id="activity.example">
																		<b>Figure 1. Display example process</b>
																</a>
														</p>
												</div>
												<p>
														<a id="activity.example">
																<br class="figure-break" />
														</a>
												</p>
												<pre class="programlisting">
														<a id="activity.example">ClientProcessDefinition processDefinition = ProcessDefinitionBuilder.startProcess("helloworld")<br />							 .startActivity("a", new Display("Hello"))<br />							 .initial()<br />							 .transition("b")<br />							 .endActivity()<br />							 .startActivity("b", new Display("World"))<br />							 .endActivity()<br />							 .endProcess();<br /></a>
												</pre>
												<p>
														<a id="activity.example">然后,你调用
</a>
												</p>
												<pre class="programlisting">
														<a id="activity.example">processDefinition.startProcessInstance();<br /></a>
												</pre>
												<p>
														<a id="activity.example">就会得到如下的结果
</a>
												</p>
												<pre class="programlisting">
														<a id="activity.example">Hello<br />World<br /></a>
												</pre>
												<p>
														<a id="activity.example">我们这个Display的节点就是采用的隐式execution执行方法.

</a>
												</p>
												<div xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="tip">
														<h2>
																<a id="activity.example">Tip</a>
														</h2>
														<a id="activity.example">细心的你会发现,我们在定义Process Defintion的时候,总是要在调用一个initial()方法.
这是设定当前这个节点为流程的启始节点.
</a>
												</div>
												<p>
														<a id="activity.example">
														</a>
												</p>
										</div>
										<div class="section" lang="en-US">
												<div class="titlepage">
														<div>
																<div>
																		<h3 class="title">
																				<a id="d0e327">3.2. ExternalActivityBehaviour(外部节点)</a>
																		</h3>
																</div>
														</div>
												</div>
												<p>
														<a id="d0e327">外部节点就是代表着,这个活动还需要系统外部的配合,比如说人工的配合才能使得这个流程继续下去.我们一般称这种的节点为 Wait State. 
因为他需要一直等待,直至外部活动的促发,然后流程才继续. 这种的节点需要实现ExternalActivityBehaviour的API.
</a>
												</p>
												<pre class="programlisting">
														<a id="d0e327">public interface ExternalActivityBehaviour extends ActivityBehaviour { <br />  //handles an external trigger.  <br />  void signal(ActivityExecution execution, String signalName, Map&lt;String, ?&gt; parameters) throws Exception;<br />}<br /></a>
												</pre>
												<p>
														<a id="d0e327">跟内部节点类似,执行到ExternalActivityBehaviour的时候,也是执行它的execute()方法,但是一般来说,在外部活动的execute()方法中,
会调用execution.waitForSignal()方法,使得activity进入一个等待状态.
直到外部调用signal()方法来使得流程再次从等待状态变成激活.一般来说在signal()方法中,会调用execution.take(signalName)根据signalName(也就是transition name)去找到
下一个节点,然后把整个流程走到下一个节点.	 
	 </a>
												</p>
												<p>
														<a id="d0e327">很简单的一个例子是,比如说一个申请审批的流程,员工递交一份申请上去,然后继续就进入一个wait state的状态,因为他需要经理的审批(也就是一个人工的活动),那么经理可以选择一个ok的signalName,使得整个
流程进入到下一个节点,这里就好比如是结束的节点,又或者使得整个流程直接结束.	 
	 </a>
												</p>
												<p>
														<a id="d0e327">我们接下来实现一个简单的WaitState,实现ExternalActivityBehaviour的接口.
</a>
												</p>
												<pre class="programlisting">
														<a id="d0e327">public class WaitState implements ExternalActivityBehaviour {<br /><br />  public void execute(ActivityExecution execution) {<br />    execution.waitForSignal();<br />  }<br /><br />  public void signal(ActivityExecution execution, <br />                     String signalName, <br />                     Map&lt;String, Object&gt; parameters) {<br />    execution.take(signalName);<br />  }<br />}	 <br /></a>
												</pre>
												<p>
														<a id="d0e327">一样的,我们来看一个简单的从a-&gt;b的流程.这次不同的是,a和b都是wait state.

    </a>
												</p>
												<div class="figure">
														<div class="figure-contents">
																<div class="mediaobject" align="center">
																		<a id="activity.example.2">
																				<img src="http://people.apache.org/%7Ejeffyu/articles/zh_CN/jbpm/images/process.ab.png" alt="The external activity example process" align="middle" />
																		</a>
																</div>
														</div>
														<p class="title">
																<a id="activity.example.2">
																		<b>Figure 2. The external activity example process</b>
																</a>
														</p>
												</div>
												<p>
														<a id="activity.example.2">
																<br class="figure-break" />
ProcessDefinition的定义    
</a>
												</p>
												<pre class="programlisting">
														<a id="activity.example.2">ClientProcessDefinition pd = ProcessDefinitionBuilder.startProcess("helloworld")<br />							 .startActivity("a", new WaitState())<br />							 .initial()<br />							 .transition("b", "b-transition")<br />							 .endActivity()<br />							 .startActivity("b", new WaitState())<br />							 .endActivity()<br />							 .endProcess();<br /></a>
												</pre>
												<p>
														<a id="activity.example.2">    
启动这个ProcessDefinition
</a>
												</p>
												<pre class="programlisting">
														<a id="activity.example.2">ClientProcessInstance instance = pd.startProcessInstance();<br />instance.isActive("a")<br /></a>
												</pre>
												<p>
														<a id="activity.example.2"> 
在启动之后,因为执行到a的时候,是一个wait state,所以,当前的流程活动应该是指向a.
如果要到b这个activity,那么就需要调用
</a>
												</p>
												<pre class="programlisting">
														<a id="activity.example.2">instance.signal("b-transition");<br />instance.isActive("b")<br /></a>
												</pre>
												<p>
														<a id="activity.example.2">  
那么,你就会发现,经过我们调用signal方法,instance根据所提供的transitionName (b-transition),找到下一个节点,也就是b.
但因为b也是一个wait state,所以此刻,整个流程就停留在了b节点身上.
	 </a>
												</p>
										</div>
										<div class="section" lang="en-US">
												<div class="titlepage">
														<div>
																<div>
																		<h3 class="title">
																				<a id="d0e358">3.3. 基本流程的实现</a>
																		</h3>
																</div>
														</div>
												</div>
												<p>
														<a id="d0e358">接下来,我们基于前面两种节点的实现,来实现一个稍微比较正式的流程(loan process).

    </a>
												</p>
												<div class="figure">
														<div class="figure-contents">
																<div class="mediaobject" align="center">
																		<a id="basicprocessexecution.loan.process">
																				<img src="http://people.apache.org/%7Ejeffyu/articles/zh_CN/jbpm/images/process.loan.png" alt="The loan process" align="middle" />
																		</a>
																</div>
														</div>
														<p class="title">
																<a id="basicprocessexecution.loan.process">
																		<b>Figure 3. The loan process</b>
																</a>
														</p>
												</div>
												<p>
														<a id="basicprocessexecution.loan.process">
																<br class="figure-break" />
ProcessDefinition的定义
</a>
												</p>
												<pre class="programlisting">
														<a id="basicprocessexecution.loan.process">	ClientProcessDefinition pd = ProcessDefinitionBuilder.startProcess("loanprocess")<br />								 .startActivity("submit loan request", new Display("submit a loan request"))<br />								 .initial()<br />								 .transition("evaluate", "evaluate-transition")<br />								 .endActivity()<br />								 .startActivity("evaluate", new WaitState())<br />								 .transition("wiremoney", "approve")<br />								 .transition("end", "reject")<br />								 .endActivity()<br />								 .startActivity("wiremoney", new Display("wire the money"))<br />								 .transition("archive")<br />								 .endActivity()<br />								 .startActivity("archive", new WaitState())<br />								 .transition("end", "done")<br />								 .endActivity()<br />								 .startActivity("end", new WaitState())<br />								 .endActivity()<br />								 .endProcess();   <br /></a>
												</pre>
												<p>
														<a id="basicprocessexecution.loan.process">启动这个processInstance
</a>
												</p>
												<pre class="programlisting">
														<a id="basicprocessexecution.loan.process">instance = pd.startProcessInstance();<br /></a>
												</pre>
												<p>
														<a id="basicprocessexecution.loan.process">启动这个processInstance后,它开始点在submit loan request这个节点,后面经过Display这个节点,默认走到了evaluate这个节点.
因为evaluate是个wait state,所以流程停在了evaluate.

  </a>
												</p>
												<div class="figure">
														<div class="figure-contents">
																<div class="mediaobject" align="center">
																		<a id="execution.loan.evaluate">
																				<img src="http://people.apache.org/%7Ejeffyu/articles/zh_CN/jbpm/images/execution.loan.evaluate.png" alt="Execution positioned in the 'evaluate' activity" align="middle" />
																		</a>
																</div>
														</div>
														<p class="title">
																<a id="execution.loan.evaluate">
																		<b>Figure 4. Execution positioned in the 'evaluate' activity</b>
																</a>
														</p>
												</div>
												<p>
														<a id="execution.loan.evaluate">
																<br class="figure-break" />
现在呢, evaluate这个节点有两条支路,一个是approve,指向wiremoney节点;另外一个是reject,直接走向end.
假设我们选择approve这条支路.
</a>
												</p>
												<pre class="programlisting">
														<a id="execution.loan.evaluate">instance.signal("approve");<br /></a>
												</pre>
												<p>
														<a id="execution.loan.evaluate">那么,我们就走向了wiremoney这个节点,因为wiremoney是个Display节点,所以它显示完后,默认的走向下一个节点,archive.
   </a>
												</p>
												<div class="figure">
														<div class="figure-contents">
																<div class="mediaobject" align="center">
																		<a id="execution.loan.archive">
																				<img src="http://people.apache.org/%7Ejeffyu/articles/zh_CN/jbpm/images/execution.loan.archive.png" alt="Execution positioned in 'archive' activity" align="middle" />
																		</a>
																</div>
														</div>
														<p class="title">
																<a id="execution.loan.archive">
																		<b>Figure 5. Execution positioned in 'archive' activity</b>
																</a>
														</p>
												</div>
												<p>
														<a id="execution.loan.archive">
																<br class="figure-break" /> 
同样的,因为archive节点是个wait state,所以需要再一次的signal,才能走到end这个节点.
</a>
												</p>
												<pre class="programlisting">
														<a id="execution.loan.archive">instance.signal("done");<br /></a>
												</pre>
												<p>
														<a id="execution.loan.archive">这样的话,整个流程就会走向了end节点.  
     </a>
												</p>
												<div class="figure">
														<div class="figure-contents">
																<div class="mediaobject" align="center">
																		<a id="execution.loan.end">
																				<img src="http://people.apache.org/%7Ejeffyu/articles/zh_CN/jbpm/images/execution.loan.end.png" alt="Execution positioned in the 'end' activity" align="middle" />
																		</a>
																</div>
														</div>
														<p class="title">
																<a id="execution.loan.end">
																		<b>Figure 6. Execution positioned in the 'end' activity</b>
																</a>
														</p>
												</div>
												<p>
														<a id="execution.loan.end">
																<br class="figure-break" />
														</a>
												</p>
										</div>
										<div class="section" lang="en-US">
												<div class="titlepage">
														<div>
																<div>
																		<h3 class="title">
																				<a id="d0e403">3.4. 事件机制 (Event and EventListener)</a>
																		</h3>
																</div>
														</div>
												</div>
												<p>
														<a id="d0e403">事件的订阅可以通过实现EventListener来实现. 
</a>
												</p>
												<pre class="programlisting">
														<a id="d0e403">public interface EventListener extends Serializable {<br />  void notify(EventListenerExecution execution) throws Exception;<br />}<br /></a>
												</pre>
												<p>
														<a id="d0e403"> 
Event概念的引入,主要是为了弥补分析员(Business Analyst)和开发人员(Developer)之间的不同需求.
developer可以使用Event在一些节点上来做一些操作(比如说操作数据库),这样呢,也不会影响整个流程,所以分析员不用去关心这些具体的Event,
他们只需要看流程是否跟他们所期望的是一致的.  	
    	</a>
												</p>
												<p>
														<a id="d0e403">具体的Event是由<span class="emphasis"><em>ObservableElement</em></span>和<span class="emphasis"><em>EventName</em></span>来构成的.
</a>
												</p>
												<pre class="programlisting">
														<a id="d0e403">public interface EventListenerExecution extends OpenExecution {<br />void fire(String eventName, ObservableElement eventSource);<br />}<br /></a>
												</pre>
												<p>
														<a id="d0e403">
														</a>
												</p>
												<p>
														<a id="d0e403">我们来实现一个简单的EventListener, 叫PrintLn
</a>
												</p>
												<pre class="programlisting">
														<a id="d0e403">public class PrintLn implements EventListener {<br /><br />	String message;<br /><br />	public PrintLn(String message) {<br />		this.message = message;<br />	}<br /><br />	public void notify(EventListenerExecution execution) throws Exception {<br />		System.out.println(message);<br />	}<br />}<br /></a>
												</pre>
												<p>
														<a id="d0e403">
														</a>
												</p>
												<div class="figure">
														<div class="figure-contents">
																<div class="mediaobject" align="center">
																		<a id="action.process">
																				<img src="http://people.apache.org/%7Ejeffyu/articles/zh_CN/jbpm/images/process.ab.png" alt="The PrintLn listener process" align="middle" />
																		</a>
																</div>
														</div>
														<p class="title">
																<a id="action.process">
																		<b>Figure 7. The PrintLn listener process</b>
																</a>
														</p>
												</div>
												<p>
														<a id="action.process">
																<br class="figure-break" />
    
我们看下是怎么来定义一个具备有Events的ProcessDefinition:
</a>
												</p>
												<pre class="programlisting">
														<a id="action.process">ClientProcessDefinition pd = ProcessDefinitionBuilder.startProcess("ab")<br />							 .startActivity("a", new Display("Testing Event"))<br />							 .initial()<br />							 .transition("b")<br />							 .startEvent(Event.END)<br />							 .listener(new PrintLn("leaving a"))<br />							 .listener(new PrintLn("second message while leaving a"))<br />							 .endEvent()<br />							 .startEvent(Event.TAKE)<br />							 .listener(new PrintLn("taking transition"))<br />							 .endEvent()<br />							 .endActivity()<br />							 .startActivity("b", new WaitState())<br />							 .startEvent(Event.START)<br />							 .listener(new PrintLn("entering b"))<br />							 .endEvent()<br />							 .endActivity()<br />							 .endProcess();<br /></a>
												</pre>
												<p>
														<a id="action.process">我们可以看到,一个事件可以有无穷多个的Listener(s).     	
    	</a>
												</p>
										</div>
										<p>
												<a id="action.process">至此,我们主要看了PVM里面内部Model的一些设计,一些核心的概念和API.
    </a>
										</p>
								</div>
								<div class="bibliography">
										<div class="titlepage">
												<div>
														<div>
																<h2 class="title">
																		<a id="d0e439">Bibliography</a>
																</h2>
														</div>
												</div>
										</div>
										<div xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="orderedlist">
												<ol>
														<li>
																<a xmlns:xlink="http://www.w3.org/1999/xlink" href="http://docs.jboss.com/jbpm/v4.0/userguide/html_single/">jBPM 4.0 User Guide</a>
														</li>
														<li>
																<a xmlns:xlink="http://www.w3.org/1999/xlink" href="http://docs.jboss.com/jbpm/v4.0/devguide/html_single/">jBPM 4.0 Developer Guide</a>
														</li>
														<li>
																<a xmlns:xlink="http://www.w3.org/1999/xlink" href="http://www.slideshare.net/guest8d4bce/spring-integration-with-jbpm4">Srping integration with jbpm4</a>
														</li>
														<li>
																<a xmlns:xlink="http://www.w3.org/1999/xlink" href="../../RongHao/archive/2009/05/07/269465.html">jBPM4的IOC容器</a>
														</li>
												</ol>
										</div>
								</div>
								<div xmlns="" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="footnotes">
										<br />
										<hr />
										<div xmlns="http://www.w3.org/1999/xhtml" class="footnote">
												<p>
														<sup>[<a id="ftn.d0e88" href="http://people.apache.org/%7Ejeffyu/articles/zh_CN/jbpm/#d0e88">1</a>] </sup>图来自于<a xmlns:xlink="http://www.w3.org/1999/xlink" href="http://people.apache.org/%7Ejeffyu/articles/zh_CN/jbpm/">http://www.blogjava.net/RongHao/archive/2009/05/07/269465.html</a></p>
										</div>
										<div xmlns="http://www.w3.org/1999/xhtml" class="footnote">
												<p>
														<sup>[<a id="ftn.d0e112" href="http://people.apache.org/%7Ejeffyu/articles/zh_CN/jbpm/#d0e112">2</a>] </sup>
														<a xmlns:xlink="http://www.w3.org/1999/xlink" href="http://people.apache.org/%7Ejeffyu/articles/zh_CN/jbpm/">http://www.jboss.org/jbossidentity</a>
												</p>
										</div>
								</div>
						</div>
				</div>
		</div>
<img src ="http://www.blogjava.net/libin2722/aggbug/286675.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/libin2722/" target="_blank">礼物</a> 2009-07-14 13:15 <a href="http://www.blogjava.net/libin2722/articles/286675.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>jBPM4的运行期环境</title><link>http://www.blogjava.net/libin2722/articles/286673.html</link><dc:creator>礼物</dc:creator><author>礼物</author><pubDate>Tue, 14 Jul 2009 05:13:00 GMT</pubDate><guid>http://www.blogjava.net/libin2722/articles/286673.html</guid><wfw:comment>http://www.blogjava.net/libin2722/comments/286673.html</wfw:comment><comments>http://www.blogjava.net/libin2722/articles/286673.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/libin2722/comments/commentRss/286673.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/libin2722/services/trackbacks/286673.html</trackback:ping><description><![CDATA[
		<div class="postTitle">
				<a id="viewpost1_TitleUrl" class="postTitle2" href="../../RongHao/archive/2009/06/17/282897.html">jBPM4的运行期环境</a>
		</div>
	        万物生长靠太阳，儿童的生长离不开土壤、空气和水，当然，也离不开绿坝娘的调教。应用程序也是如此，离不开数据库连接、事务、日志、消息等，这些，共同构成了应用程序的运行期环境。<br />
       
理想中的环境是什么样子的哩。好吧，一句话，召之即来，挥之即去，当需要某个服务时，ok，打个响指，该服务就准备好被调用了，调用完毕后也不用费心费力
地擦屁股，不必老是提心吊胆有好事者追问：你擦了吗，确定擦了？真的确定擦了？直接丢弃给环境降解处理，自然又环保，还有个好名声叫专注领域逻辑。<br /><br /><strong>一、    运行期环境就是一个餐馆</strong><br />
1、    提供必要的服务<br />
作为一个餐馆，必须有厨师做饭我吃，必须有桌子和椅子。作为运行期环境同样如此，我要发消息，你得提供我发消息的Service，我要获取节点任务，你得扔给我TaskService。<br /><br />
2、    提供获取这些服务的统一方式<br />
好吧，我不会亲自到厨房告诉厨师我想吃什么（因为我担心这样一来我会吃不下去），我也不会亲自到收银台给钱。这些服务有一个统一的获取方式：服务员。我想
吃什么和结账，告诉服务员即可。关键是这一方式要统一，要足够简单。Spring最懒，把服务给你全部注入了，当然你也可以握住BeanFactory的
纤纤细手，一个一个的get。<br /><br />
3、    提供特定于我线程不安全的服务<br />
我点了一盘鱼香肉丝，隔壁也点了一盘鱼香肉丝，结果服务员让我们吃同一盘鱼香肉丝。我立刻跳起来：靠，你们的服务不是线程安全的吗？！Hibernate
的Session正是属于这么一种情况，需要环境进行隔离，我的唯一职责就是吃饭！我的领域逻辑是如何优美的进餐！为此还要不断重构我吃饭的姿势哩。<br />
好不容易吃完饭，付完款，正准备离场。服务员风度翩翩地走到我的身旁，我以为还有打折券供应，结果是：服务员小姐轻启朱唇：先生，麻烦您把吃剩的盘子清洗完毕。<br />
崩溃！<br />
像数据库连接的打开，关闭、事务的打开、提交等都属于运行期环境应该做的事情。<br /><br />
4、    其他的七七八八<br />
杂事不少，例如统一的事件机制、权限拦截等等。<br /><br /><strong>二、    jBPM4的运行期环境</strong><br />
好吧，先来看看如何建立jBPM4的运行期环境：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">EnvironmentFactory environmentFactory </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> DefaultEnvironmentFactory();<br />
 <br />
  <img src="../../Images/dot.gif" alt="" /><br />
 <br />
  Environment environment </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> environmentFactory.openEnvironment();<br />
  </span><span style="color: rgb(0, 0, 255);">try</span><span style="color: rgb(0, 0, 0);"> {<br />
 <br />
    <img src="../../Images/dot.gif" alt="" /> everything available in </span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);"> block <img src="../../Images/dot.gif" alt="" /><br />
 <br />
  } </span><span style="color: rgb(0, 0, 255);">finally</span><span style="color: rgb(0, 0, 0);"> {<br />
    environment.close();<br />
  }</span></div><br /><br />
两个关键的类：EnvironmentFactory和Environment。<br /><br />
EnvironmentFactory是全局的，在整个应用程序中保持一个实例即可。<br /><br />
Environment则是每次方法调用则要new一个。<br /><br />
看看Environment的主要方法：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">abstract</span><span style="color: rgb(0, 0, 0);"> Object get(String name);<br /></span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">abstract</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">T</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"> T get(Class</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">T</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"> type);</span></div><br /><br />
是的，environment为我们的代码提供所需要的服务类实例。<br /><br />
那么，如何获得environment？<br />
继续看：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> Environment getCurrent()；</span></div><br />
static，我喜欢也。方便、快捷，不管是在地上、车上还是房顶上，随处都可调用。<br /><br />
那么，为什么Environment每次调用要new呢？<br />
好吧，当你需要获取数据库Session的时候，是不是每次都要new呢。Environment提供的服务里包括了非线程安全的数据库操作服务。<br /><br />
三、    jBPM4运行期环境的实现<br /><br />
1、JbpmConfiguration<br />
JbpmConfiguration是jBPM4里最重要的类，它是整个应用程序的入口。它实现了EnvironmentFactory接口。<br /><br />
      JbpmConfiguration加载jBPM总的配置文件，还是大概扫一下这个配置文件：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">      </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">jbpm</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">configuration xmlns</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">http://jbpm.org/xsd/cfg</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br />
  </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">process</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">engine</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">context</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
 <br />
    </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">repository</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">service </span><span style="color: rgb(0, 0, 0);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />
    </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">repository</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">cache </span><span style="color: rgb(0, 0, 0);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />
    </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">execution</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">service </span><span style="color: rgb(0, 0, 0);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />
    </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">history</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">service </span><span style="color: rgb(0, 0, 0);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />
    </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">management</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">service </span><span style="color: rgb(0, 0, 0);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />
    </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">identity</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">service </span><span style="color: rgb(0, 0, 0);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />
    </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">task</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">service </span><span style="color: rgb(0, 0, 0);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br />
    </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">hibernate</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">configuration</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
      </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">cfg resource</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">jbpm.hibernate.cfg.xml</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">/&gt;</span><span style="color: rgb(0, 0, 0);">    <br />
    </span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">hibernate</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">configuration</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br />
    </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">hibernate</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">session</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">factory </span><span style="color: rgb(0, 0, 0);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />
 <br />
  </span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">process</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">engine</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">context</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br />
  </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">transaction</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">context</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
    </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">repository</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">session </span><span style="color: rgb(0, 0, 0);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />
    </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">pvm</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">db</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">session </span><span style="color: rgb(0, 0, 0);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />
    </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">job</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">db</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">session </span><span style="color: rgb(0, 0, 0);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />
    </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">task</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">db</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">session </span><span style="color: rgb(0, 0, 0);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />
    </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">message</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">session </span><span style="color: rgb(0, 0, 0);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />
    </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">timer</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">session </span><span style="color: rgb(0, 0, 0);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />
    </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">history</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">session </span><span style="color: rgb(0, 0, 0);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />
  </span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">transaction</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">context</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br /></span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">jbpm</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">configuration</span><span style="color: rgb(0, 0, 0);">&gt;</span></div><br /><br />
配置文件被分为了两部分，分别是：process-engine-context和transaction-context。<br />
对应于两个IOC容器（WireContext）的配置文件。<br /><br />
作为EnvironmentFactory，JbpmConfiguration持有成品process-engine-context对应的IOC容器
（全局的）实例，持有半成品transaction-context的WireDefinition。当调用openEnvironment方法
时，JbpmConfiguration会new Environment，然后将process-engine-context
IOC填充入environment，同时初始化transaction-context
IOC，并将其也填充入environment。这样通过environment就可以获得所有所需要的服务，包括全局的和非线程安全的服务实例。也就是
environment透过IOC容器提供了查找各种服务的能力。<br /><br /><img alt="" src="../../images/blogjava_net/ronghao/Environment.png" /><br />
 <br /><br />
2、与线程绑定的environment<br />
environment初始化之后,避免参数传递得一塌糊涂的方式就是将environment与线程绑定。看Environment的代码：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> ThreadLocal</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">Environment</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"> currentEnvironment </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> ThreadLocal</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">Environment</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">();<br /><br />
  </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> ThreadLocal</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">Stack</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">Environment</span><span style="color: rgb(0, 0, 0);">&gt;&gt;</span><span style="color: rgb(0, 0, 0);"> currentEnvironmentStack </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> ThreadLocal</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">Stack</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">Environment</span><span style="color: rgb(0, 0, 0);">&gt;&gt;</span><span style="color: rgb(0, 0, 0);">();</span></div><br /><br />
是的，在openEnvironment时，有这么一行代码：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">Environment.pushEnvironment(environment);</span></div><br /><br />
这样environment就与线程绑定了，可以通过Environment.getCurrent()任意调用了。<br /><br />
哪里有压迫，哪里就有放抗。<br />
在environment.close()方法里：<br /><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">Environment.popEnvironment();</span></div><br /><br />
OK，结束。<br /><br /><img src ="http://www.blogjava.net/libin2722/aggbug/286673.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/libin2722/" target="_blank">礼物</a> 2009-07-14 13:13 <a href="http://www.blogjava.net/libin2722/articles/286673.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Jbpm4的IOC容器</title><link>http://www.blogjava.net/libin2722/articles/286520.html</link><dc:creator>礼物</dc:creator><author>礼物</author><pubDate>Mon, 13 Jul 2009 02:34:00 GMT</pubDate><guid>http://www.blogjava.net/libin2722/articles/286520.html</guid><wfw:comment>http://www.blogjava.net/libin2722/comments/286520.html</wfw:comment><comments>http://www.blogjava.net/libin2722/articles/286520.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/libin2722/comments/commentRss/286520.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/libin2722/services/trackbacks/286520.html</trackback:ping><description><![CDATA[和Jbpm3一样，Jbpm4实现了自己的IOC容器。以现在的眼光看来，应用程序里一个IOC容器几乎是居家必备的，否则，又要平白多出一坨一坨的工厂类和单态类来。<br /><br /><strong>一、    Jbpm4 IOC容器介绍</strong><br />
IOC容器的目的是管理组件和实现组件之间的解耦。和Spring里的BeanFactory对应，Jbpm4里的接口是Context，具体实现则是
WireContext。Context实际在Jbpm4里有更多的含义，它与Environment一起，共同构成了代码运行的运行期环境。在这个环境
里可以获取系统的组件，更为重要的是提供了数据库连接（session）和事务（这个稍后会讲）。<br /><br />
先来看看Context接口的核心方法：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">      Object get(String key);<br />
  </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">T</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"> T get(Class</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">T</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"> type);</span></div><br /><br />
很明显，提供两种从容器里获取组件的方法，一种是通过name，一种是通过type。<br /><br />
对于IOC容器来说，一般情况下都会提供一种加载的方式，比如从xml文件进行加载、从资源文件进行加载。Jbpm4透过WireParser具备从xml加载的能力。<br /><br />
此外，WireContext通过一个Map缓存初始化后的组件。<br /><br /><strong>二、    Jbpm4 IOC容器实现</strong><br />
容器的实现有五个关键类和接口，分别是：WireParser、Binding、Descriptor、WireDefinition和WireContext。<br />
 <br /><img alt="" src="../../images/blogjava_net/ronghao/IOC.png" width="932" height="456" /><br />
WireParser读取xml文件，同时WireParser会加载一系列的Binding(默认从jbpm.wire.bindins.xml文件读取加载)。<br /><br />
Binding负责根据xml里元素的tag将xml元素转换为对应的Descriptor。<br /><br />
Descriptor负责初始化对象。它们被添加到WireDefinition。<br /><br />
WireDefinition被WireParser返回给WireContext。WireContext创建对象时会访问WireDefinition里的Descriptor，同时将初始化对象的任务委托给Descriptor自身。<br /><br />
需要注意的是：Jbpm4在初始化对象时有着四种策略，分别是：延迟创建和初始化、延迟创建和立刻初始化、立刻创建和延迟初始化、立刻创建和立刻初始化。<br /><br />
立刻创建：在WireContext创建完毕后对象就已经创建。<br />
延迟创建：调用WireContext的get方法获取该对象时才创建该对象。<br />
初始化：一般完成对象属性的注入等操作。<br /><br /><strong>三、    Jbpm4 IOC容器在Jbpm4里的应用</strong><br />
IOC容器在Jbpm4里最重要的作用就是加载Jbpm的总的配置文件（默认是jbpm.cfg.xml），这也是整个Jbpm应用的起点。大概扫一下这个配置文件：<br /><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 255);">&lt;?</span><span style="color: rgb(255, 0, 255);">xml version="1.0" encoding="UTF-8"</span><span style="color: rgb(0, 0, 255);">?&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">jbpm-configuration </span><span style="color: rgb(255, 0, 0);">xmlns</span><span style="color: rgb(0, 0, 255);">="http://jbpm.org/xsd/cfg"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br />
  </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">process-engine-context</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
 <br />
    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">repository-service </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />
    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">repository-cache </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />
    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">execution-service </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />
    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">history-service </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />
    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">management-service </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />
    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">identity-service </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />
    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">task-service </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br />
    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">hibernate-configuration</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
      </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">cfg </span><span style="color: rgb(255, 0, 0);">resource</span><span style="color: rgb(0, 0, 255);">="jbpm.hibernate.cfg.xml"</span><span style="color: rgb(255, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);">    <br />
    </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">hibernate-configuration</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br />
    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">hibernate-session-factory </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />
 <br />
  </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">process-engine-context</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br />
  </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">transaction-context</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">repository-session </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />
    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">pvm-db-session </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />
    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">job-db-session </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />
    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">task-db-session </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />
    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">message-session </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />
    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">timer-session </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />
    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">history-session </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />
  </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">transaction-context</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br /></span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">jbpm-configuration</span><span style="color: rgb(0, 0, 255);">&gt;</span></div><br /><br />
可以看到配置文件被分为了两部分，分别是：process-engine-context和transaction-context。在实际应用中，它们
分别对应着两个不同的WireContext:ProcessEngineContext和TransactionConext。
ProcessEngineContext覆盖了jbpm4里最重要的服务类，这些类是全局唯一的，当然，ProcessEngineContext也是
独此一份。本是同根生，命运各不同。TransactionConext则是在每次openEnvironment时重新创建，因为其包含了数据库连接和
事务。<br /><br />
贯穿于整个Jbpm4中，这两个Context被压到Environment里（Environment和线程绑定），在任何需要的地方都能提供一条龙的服务。于是，在很多领域类里，利用这些服务实现充血模型就是很顺理成章的一件事了。<br /><br />
总结: ProcessEngineContext给引擎领域模型提供全局的组件查找；TransactionConext提供数据库相关服务。<br /><br /><img src ="http://www.blogjava.net/libin2722/aggbug/286520.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/libin2722/" target="_blank">礼物</a> 2009-07-13 10:34 <a href="http://www.blogjava.net/libin2722/articles/286520.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>jBPM4任务管理：参与模式一瞥</title><link>http://www.blogjava.net/libin2722/articles/286518.html</link><dc:creator>礼物</dc:creator><author>礼物</author><pubDate>Mon, 13 Jul 2009 02:32:00 GMT</pubDate><guid>http://www.blogjava.net/libin2722/articles/286518.html</guid><wfw:comment>http://www.blogjava.net/libin2722/comments/286518.html</wfw:comment><comments>http://www.blogjava.net/libin2722/articles/286518.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/libin2722/comments/commentRss/286518.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/libin2722/services/trackbacks/286518.html</trackback:ping><description><![CDATA[
		<p>原文地址：<a href="http://www.jboss.org/feeds/post/jbpm_task_management_a_look_at_the_participation_model">http://www.jboss.org/feeds/post/jbpm_task_management_a_look_at_the_participation_model</a></p>
		<p>jBPM 任务管理：参与模式一瞥<br />
Posted on 2009-03-30 09:41:00.0 by Heiko Braun<br />
Since 4.0.0 Beta1<br />
重新回顾jBPM中的任务管理模型，引进了一个新的概念：任务参与。参与模型描述了identies（用户或组）和任务在实际完成中的参与类型：<br /><img alt="" src="http://www.opug.org.cn/sites/default/files/participation.jpg" /> <br />
示例1：用户和业务管理员参与<br />
在此与这个模型非常适合的一个通常的案例是在一个实际执行任务的用户和一个业务管理员监控进展情况之间的区别。依赖于参与类型，某些规则将实际起作用，而其它的将确保任务在给定的约束内被执行（例如，优先级，预定日期等）。</p>
		<p>示例2：具有不同的参与类型的任务利益相关者<br />
另一个例子可能是利益相关者监控任务的实际输出，或者是在一个任务上互相协作的不同参与者之间的委托。在这个案例中，一个任务的发起人，一个候选人执行这个工作并且最终的与受者可能是不同的参与类型。</p>
		<p>The TaskService API已经反映了那些变化：</p>
		<p> </p>
		<pre class="java5">
				<ol>
						<li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;">
								<div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;">org.<span style="color: rgb(0, 102, 0);">jbpm</span>.<span style="color: rgb(0, 102, 0);">TaskService</span><span style="color: rgb(102, 204, 102);">{</span></div>
						</li>
						<li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;">
								<div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> </div>
						</li>
						<li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;">
								<div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;">
										<span style="color: rgb(102, 204, 102);">[</span>...<span style="color: rgb(102, 204, 102);">]</span></div>
						</li>
						<li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;">
								<div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> </div>
						</li>
						<li style="font-weight: bold;">
								<div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;">
										<span style="color: rgb(128, 128, 128); font-style: italic;">/**</span>
								</div>
						</li>
						<li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;">
								<div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;">
										<span style="color: rgb(128, 128, 128); font-style: italic;">   * retrieves a list of tasks for a user</span>
								</div>
						</li>
						<li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;">
								<div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;">
										<span style="color: rgb(128, 128, 128); font-style: italic;">   * and a particular {@link org.jbpm.task.Participation} type</span>
								</div>
						</li>
						<li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;">
								<div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;">
										<span style="color: rgb(128, 128, 128); font-style: italic;">   *</span>
								</div>
						</li>
						<li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;">
								<div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;">
										<span style="color: rgb(128, 128, 128); font-style: italic;">   * @see org.jbpm.TaskQuery</span>
								</div>
						</li>
						<li style="font-weight: bold;">
								<div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;">
										<span style="color: rgb(128, 128, 128); font-style: italic;">   */</span>
								</div>
						</li>
						<li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;">
								<div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> </div>
						</li>
						<li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;">
								<div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;">
										<a href="http://www.google.com/search?sitesearch=java.sun.com&amp;q=allinurl%3Aj2se%2F1+5+0%2Fdocs%2Fapi+List">
												<span style="color: rgb(170, 170, 221); font-weight: bold;">List</span>
										</a> findTasksByParticipation<span style="color: rgb(102, 204, 102);">(</span><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html"><span style="color: rgb(170, 170, 221); font-weight: bold;">String</span></a> participation, UserRef user<span style="color: rgb(102, 204, 102);">)</span>;</div>
						</li>
						<li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;">
								<div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> </div>
						</li>
						<li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;">
								<div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;">
										<span style="color: rgb(128, 128, 128); font-style: italic;">/**</span>
								</div>
						</li>
						<li style="font-weight: bold;">
								<div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;">
										<span style="color: rgb(128, 128, 128); font-style: italic;">   * retrieves a list of tasks for a group</span>
								</div>
						</li>
						<li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;">
								<div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;">
										<span style="color: rgb(128, 128, 128); font-style: italic;">   * and a particular {@link org.jbpm.task.Participation} type</span>
								</div>
						</li>
						<li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;">
								<div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;">
										<span style="color: rgb(128, 128, 128); font-style: italic;">   *</span>
								</div>
						</li>
						<li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;">
								<div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;">
										<span style="color: rgb(128, 128, 128); font-style: italic;">   * @see org.jbpm.TaskQuery </span>
								</div>
						</li>
						<li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;">
								<div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;">
										<span style="color: rgb(128, 128, 128); font-style: italic;">   */</span>
								</div>
						</li>
						<li style="font-weight: bold;">
								<div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> </div>
						</li>
						<li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;">
								<div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;">
										<a href="http://www.google.com/search?sitesearch=java.sun.com&amp;q=allinurl%3Aj2se%2F1+5+0%2Fdocs%2Fapi+List">
												<span style="color: rgb(170, 170, 221); font-weight: bold;">List</span>
										</a> findTasksByParticipation<span style="color: rgb(102, 204, 102);">(</span><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html"><span style="color: rgb(170, 170, 221); font-weight: bold;">String</span></a> participation, GroupRef... <span style="color: rgb(0, 102, 0);">groups</span><span style="color: rgb(102, 204, 102);">)</span>;</div>
						</li>
						<li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;">
								<div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> </div>
						</li>
						<li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;">
								<div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;">
										<span style="color: rgb(102, 204, 102);">}</span>
								</div>
						</li>
				</ol>
		</pre>
		<p>目前，我们封装了一些默认的参与类型，其中仅仅支持“候选人”模型，但是你可以期待这些将在不久的将来被扩展实现。</p>
		<p> </p>
		<p> </p>
		<pre class="java5">
				<ol>
						<li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;">
								<div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;">org.<span style="color: rgb(0, 102, 0);">jbpm</span>.<span style="color: rgb(0, 102, 0);">task</span>.<span style="color: rgb(0, 102, 0);">Participation</span><span style="color: rgb(102, 204, 102);">{</span></div>
						</li>
						<li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;">
								<div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;">
										<span style="color: rgb(102, 204, 102);">[</span>...<span style="color: rgb(102, 204, 102);">]</span></div>
						</li>
						<li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;">
								<div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;">
										<a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html">
												<span style="color: rgb(170, 170, 221); font-weight: bold;">String</span>
										</a> CANDIDATE = <span style="color: rgb(255, 0, 0);">"candidate"</span>;</div>
						</li>
						<li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;">
								<div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;">IdentityRef getIdentityRef<span style="color: rgb(102, 204, 102);">(</span><span style="color: rgb(102, 204, 102);">)</span>;</div>
						</li>
						<li style="font-weight: bold;">
								<div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;">
										<span style="color: rgb(128, 128, 128); font-style: italic;">/** see constants for default participations */</span>
								</div>
						</li>
						<li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;">
								<div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;">
										<a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html">
												<span style="color: rgb(170, 170, 221); font-weight: bold;">String</span>
										</a> getType<span style="color: rgb(102, 204, 102);">(</span><span style="color: rgb(102, 204, 102);">)</span>;</div>
						</li>
						<li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;">
								<div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;">
										<span style="color: rgb(102, 204, 102);">}</span>
								</div>
						</li>
				</ol>
		</pre>
		<p>敬请期待。</p>
<img src ="http://www.blogjava.net/libin2722/aggbug/286518.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/libin2722/" target="_blank">礼物</a> 2009-07-13 10:32 <a href="http://www.blogjava.net/libin2722/articles/286518.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title> jBPM4管理控制台一瞥</title><link>http://www.blogjava.net/libin2722/articles/286517.html</link><dc:creator>礼物</dc:creator><author>礼物</author><pubDate>Mon, 13 Jul 2009 02:29:00 GMT</pubDate><guid>http://www.blogjava.net/libin2722/articles/286517.html</guid><wfw:comment>http://www.blogjava.net/libin2722/comments/286517.html</wfw:comment><comments>http://www.blogjava.net/libin2722/articles/286517.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/libin2722/comments/commentRss/286517.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/libin2722/services/trackbacks/286517.html</trackback:ping><description><![CDATA[
		<span style="font-size: 10.5pt; font-family: 宋体;">JBoss已经发布了jBPM4
Alpha1版本，而2008年12月，Red
Hat发布公告，已经与google签署了团体共享协议，正式采用GWT作为JBoss中间件核心组成部分，而jBPM4也作为整个JBoss
SOA治理体系的核心项目。Heiko Braun在JBoss SOA 治理项目的博客（<a href="http://jboss-overlord.blogspot.com/">http://jboss-overlord.blogspot.com/</a>）上给出了基于GWT的jBPM4的管理控制台一瞥。下面是我的翻译：</span>
		<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left">
				<span style="font-size: small;">
						<span style="font-family: 宋体;">新的</span>
						<span lang="EN-US">
								<span style="font-family: Calibri;">BPM</span>
						</span>
						<span style="font-family: 宋体;">控制台已经发布了第一个里程碑，我很高兴利用这个机会介绍它最重要的改变及新特性。</span>
				</span>
				<span lang="EN-US">
						<img src="http://p.blog.csdn.net/images/p_blog_csdn_net/snow_fox_yaya/EntryImages/20090214/1-definition-list.png" alt="" width="914" height="855" />
				</span>
		</p>
		<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;" align="center">
				<span style="font-family: 宋体;">
						<span style="font-size: small;">流程定义管理</span>
				</span>
		</p>
		<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left">
				<span style="font-size: small;">
						<span style="font-family: 宋体;">迁移到</span>
						<span lang="EN-US">
								<span style="font-family: Calibri;">GWT</span>
						</span>
				</span>
		</p>
		<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left">
				<span style="font-size: small;">
						<span style="font-family: 宋体;">越来越多的</span>
						<span lang="EN-US">
								<span style="font-family: Calibri;">JBoss </span>
						</span>
						<span style="font-family: 宋体;">项目正在迁移到</span>
						<span lang="EN-US">
								<span style="font-family: Calibri;">GWT</span>
						</span>
						<span style="font-family: 宋体;">。他们这么做的原因是：</span>
				</span>
		</p>
		<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt; text-indent: -21pt; text-align: left;" align="left">
				<span style="font-family: Wingdings;" lang="EN-US">
						<span style="">
								<span style="font-size: small;">Ø</span>
								<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">  </span>
						</span>
				</span>
				<span style="font-size: small;">
						<span style="font-family: 宋体;">如果你熟悉</span>
						<span lang="EN-US">
								<span style="font-family: Calibri;">Java</span>
						</span>
						<span style="font-family: 宋体;">的开发并且不想成为下一代</span>
						<span lang="EN-US">
								<span style="font-family: Calibri;">web</span>
						</span>
						<span style="font-family: 宋体;">开发的专家，那么</span>
						<span lang="EN-US">
								<span style="font-family: Calibri;">GWT</span>
						</span>
						<span style="font-family: 宋体;">是一个比较好的选择。使用</span>
						<span lang="EN-US">
								<span style="font-family: Calibri;">GWT</span>
						</span>
						<span style="font-family: 宋体;">你可以粘住</span>
						<span lang="EN-US">
								<span style="font-family: Calibri;">eclipse</span>
						</span>
						<span style="font-family: 宋体;">，发动一个调试并且编写单元测试；</span>
				</span>
		</p>
		<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt; text-indent: -21pt; text-align: left;" align="left">
				<span style="font-family: Wingdings;" lang="EN-US">
						<span style="">
								<span style="font-size: small;">Ø</span>
								<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">  </span>
						</span>
				</span>
				<span style="font-size: small;">
						<span style="font-family: 宋体;">它有一套丰富的</span>
						<span lang="EN-US">
								<span style="font-family: Calibri;">UI</span>
						</span>
						<span style="font-family: 宋体;">窗口部件，你可以立马使用。这种窗口部件通过自己的实现保证了一个统一的外观和感觉；</span>
				</span>
		</p>
		<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left">
				<span style="font-size: small;">
						<span style="font-family: 宋体;">其它的比较好的成功的</span>
						<span lang="EN-US">
								<span style="font-family: Calibri;">GWT</span>
						</span>
						<span style="font-family: 宋体;">实施的例子就是</span>
						<span lang="EN-US">
								<span style="font-family: Calibri;">Drools </span>
						</span>
						<span style="font-family: 宋体;">控制台了。（</span>
						<span lang="EN-US">
								<span style="font-family: Calibri;">JBoss</span>
						</span>
						<span style="font-family: 宋体;">开源的规则引擎）。</span>
				</span>
		</p>
		<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"> </p>
		<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;" align="center">
				<span style="font-family: 宋体;">
						<span style="font-size: small;">
								<img src="http://p.blog.csdn.net/images/p_blog_csdn_net/snow_fox_yaya/EntryImages/20090214/2-instance-list.png" alt="" width="914" height="855" />
						</span>
				</span>
		</p>
		<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;" align="center">
				<span style="font-family: 宋体;">
						<span style="font-size: small;">流程实例管理</span>
				</span>
		</p>
		<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left">
				<span style="font-size: small;">
						<span lang="EN-US">
								<span style="font-family: Calibri;">GWT</span>
						</span>
						<span style="font-family: 宋体;">已经非常的流行了，它允许通过项目来集成控制台。另一方面的影响就是，你可以轻松地开发一个完整的</span>
						<span lang="EN-US">
								<span style="font-family: Calibri;">GWT</span>
						</span>
						<span style="font-family: 宋体;">应用，或者是一部分，并且同已经存在的</span>
						<span lang="EN-US">
								<span style="font-family: Calibri;">web</span>
						</span>
						<span style="font-family: 宋体;">应用整合在一起。举例来说，这样可以允许用户将</span>
						<span lang="EN-US">
								<span style="font-family: Calibri;">BPM</span>
						</span>
						<span style="font-family: 宋体;">控制台的任务管理功能嵌入到他们自己的内网应用中。</span>
				</span>
		</p>
		<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left">
				<span style="font-size: small;">
						<span style="font-family: 宋体;">
								<img src="http://p.blog.csdn.net/images/p_blog_csdn_net/snow_fox_yaya/EntryImages/20090214/3-instance-detail.png" alt="" />
						</span>
				</span>
		</p>
		<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"> </p>
		<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;">
				<span style="font-size: small;">
						<span lang="EN-US">
								<span style="font-family: Calibri;">流程实例细节</span>
						</span>
				</span>
		</p>
		<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;">
				<span style="font-size: small;">
						<span lang="EN-US">
						</span>
				</span>
		</p>
		<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left">
				<span style="font-size: small;">
						<span lang="EN-US">
								<span style="font-family: Calibri;">BAM</span>
						</span>
						<span style="font-family: 宋体;">（业务活动监控）及</span>
						<span lang="EN-US">
								<span style="font-family: Calibri;">BI</span>
						</span>
						<span style="font-family: 宋体;">（商业智能）功能的改进</span>
				</span>
		</p>
		<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left">
				<span style="font-size: small;">
						<span style="font-family: 宋体;">或许当前控制台的最大缺点就是缺少</span>
						<span lang="EN-US">
								<span style="font-family: Calibri;">BAM</span>
						</span>
						<span style="font-family: 宋体;">和</span>
						<span lang="EN-US">
								<span style="font-family: Calibri;">BI</span>
						</span>
						<span style="font-family: 宋体;">特性。</span>
				</span>
		</p>
		<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left">
				<span style="font-size: small;">
						<span style="font-family: 宋体;">
								<img src="http://p.blog.csdn.net/images/p_blog_csdn_net/snow_fox_yaya/EntryImages/20090214/5-metric-overview.png" alt="" width="914" height="855" />
						</span>
				</span>
		</p>
		<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"> </p>
		<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;" align="center">
				<span style="font-family: 宋体;">
				</span>
		</p>
		<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;" align="center">
				<span style="font-family: 宋体;">
						<span style="font-size: small;">工作负载概览</span>
				</span>
		</p>
		<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left">
				<span style="font-size: small;">
						<span style="font-family: 宋体;">改进</span>
						<span lang="EN-US">
								<span style="font-family: Calibri;">BAM</span>
						</span>
						<span style="font-family: 宋体;">和</span>
						<span lang="EN-US">
								<span style="font-family: Calibri;">BI</span>
						</span>
						<span style="font-family: 宋体;">不可能在一天内马上实现，但是你可以期待在早期的发布版本中看到第一个度量及状态监控，在我们实现一个功能齐全的</span>
						<span lang="EN-US">
								<span style="font-family: Calibri;">BAM</span>
						</span>
						<span style="font-family: 宋体;">控制台的过程中，我们正尽力增加更多的零星的功能。因为这将与服务活动监控项目中的功能和技术发生重叠，感兴趣的读者可以关注一下</span>
						<span lang="EN-US">
								<span style="font-family: Calibri;">SAM</span>
						</span>
						<span style="font-family: 宋体;">。</span>
				</span>
		</p>
		<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"> </p>
		<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;" align="center">
				<span style="font-family: 宋体;">
						<span style="font-size: small;">
								<img src="http://p.blog.csdn.net/images/p_blog_csdn_net/snow_fox_yaya/EntryImages/20090214/6-metric-detail.png" alt="" width="914" height="855" />
						</span>
				</span>
		</p>
		<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;" align="center">
				<span style="font-family: 宋体;">
						<span style="font-size: small;">性能度量</span>
				</span>
		</p>
		<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left">
				<span style="font-family: 宋体;">
						<span style="font-size: small;">如何迁移</span>
				</span>
		</p>
		<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left">
				<span style="font-size: small;">
						<span style="font-family: 宋体;">首先，我们将基于</span>
						<span lang="EN-US">
								<span style="font-family: Calibri;">GWT</span>
						</span>
						<span style="font-family: 宋体;">提供一个现存</span>
						<span lang="EN-US">
								<span style="font-family: Calibri;">jBPM</span>
						</span>
						<span style="font-family: 宋体;">控制台的替代。它将仍然保持当前的功能特性，但是会增加</span>
						<span lang="EN-US">
								<span style="font-family: Calibri;">BI</span>
						</span>
						<span style="font-family: 宋体;">功能。最初我们会平衡</span>
						<span lang="EN-US">
								<span style="font-family: Calibri;">jBPM3</span>
						</span>
						<span style="font-family: 宋体;">的后端功能，然后逐渐地利用</span>
						<span lang="EN-US">
								<span style="font-family: Calibri;">SAM</span>
						</span>
						<span style="font-family: 宋体;">的空间来丰富它，甚至最终完全代替它。</span>
				</span>
		</p>
		<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"> </p>
		<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;" align="center">
				<span style="font-family: 宋体;">
						<span style="font-size: small;">
								<img src="http://p.blog.csdn.net/images/p_blog_csdn_net/snow_fox_yaya/EntryImages/20090214/4-Enlarge-process.png" alt="" width="914" height="855" />
						</span>
				</span>
		</p>
		<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;" align="center">
				<span style="font-family: 宋体;">
						<span style="font-size: small;">流程图形视图</span>
				</span>
		</p>
		<p>
				<span style="font-size: 10.5pt; font-family: 宋体;">继续关注。下次我们将要详细说明实现细节，包括：</span>
				<span style="font-size: 10.5pt; font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;" lang="EN-US">gchart</span>
				<span style="font-size: 10.5pt; font-family: 宋体;">，</span>
				<span style="font-size: 10.5pt; font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;" lang="EN-US">gwt</span>
				<span style="font-size: 10.5pt; font-family: 宋体;">和</span>
				<span style="font-size: 10.5pt; font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;" lang="EN-US">gwt-ext</span>
				<span style="font-size: 10.5pt; font-family: 宋体;">。</span>
		</p>
		<p>
				<span style="font-size: 10.5pt; font-family: 宋体;">说明：此文英文链接：<a href="http://jboss-overlord.blogspot.com/2008/08/first-glimpse-at-new-bpm-console.html">http://jboss-overlord.blogspot.com/2008/08/first-glimpse-at-new-bpm-console.html</a></span>
		</p>
<img src ="http://www.blogjava.net/libin2722/aggbug/286517.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/libin2722/" target="_blank">礼物</a> 2009-07-13 10:29 <a href="http://www.blogjava.net/libin2722/articles/286517.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>jbpm3与jbpm4实现对比</title><link>http://www.blogjava.net/libin2722/articles/286513.html</link><dc:creator>礼物</dc:creator><author>礼物</author><pubDate>Mon, 13 Jul 2009 02:18:00 GMT</pubDate><guid>http://www.blogjava.net/libin2722/articles/286513.html</guid><wfw:comment>http://www.blogjava.net/libin2722/comments/286513.html</wfw:comment><comments>http://www.blogjava.net/libin2722/articles/286513.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/libin2722/comments/commentRss/286513.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/libin2722/services/trackbacks/286513.html</trackback:ping><description><![CDATA[
		<div class="Section1" style="">
				<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;" align="center">
						<span style="font-size: 16pt;" lang="EN-US">
								<span style="font-family: Calibri;">jBPM3 vs jBPM4</span>
						</span>
				</p>
				<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left">
						<span style="font-size: small;">
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">JBoss Goup</span>
								</span>
								<span style="font-family: 宋体;">目前已经发布了</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">jBPM4 Alpha1</span>
								</span>
								<span style="font-family: 宋体;">版本，在版本</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">4</span>
								</span>
								<span style="font-family: 宋体;">中最大的变化就是引入</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">PVM</span>
								</span>
								<span style="font-family: 宋体;">（流程虚拟机）的概念，而引擎内部的调度算法中重要的</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">Token</span>
								</span>
								<span style="font-family: 宋体;">机制，在新版中也去掉了，纵观整个代码，变化可以说非常的大，笔者接下来就试着来比较一下这种变化，让大家能有个直观的认识。当然</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">Jbpm4</span>
								</span>
								<span style="font-family: 宋体;">在</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">JBoss</span>
								</span>
								<span style="font-family: 宋体;">的官方网站上的</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">Road map</span>
								</span>
								<span style="font-family: 宋体;">中，在今年的</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">7</span>
								</span>
								<span style="font-family: 宋体;">月</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">1</span>
								</span>
								<span style="font-family: 宋体;">号才会发布第一个正式版本，因此后续可能还会有变化。</span>
						</span>
				</p>
				<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 18pt; text-indent: -18pt; text-align: left;" align="left">
						<span style="" lang="EN-US">
								<span style="">
										<span style="font-family: Calibri; font-size: small;">1、</span>
										<span style="font-family: 'Times New Roman';">  </span>
								</span>
						</span>
						<span style="font-size: small;">
								<span style="font-family: 宋体;">流程定义对象的变化：</span>
						</span>
				</p>
				<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 18pt; text-indent: 0cm; text-align: left;" align="left">
						<span style="font-size: small;">
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">Jbpm3</span>
								</span>
								<span style="font-family: 宋体;">流程定义对象关系图：</span>
						</span>
				</p>
				<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 18pt; text-indent: 0cm; text-align: left;" align="left">
						<span style="font-size: small;">
								<span style="font-family: 宋体;">
										<img src="http://www.javaeye.com/upload/attachment/75901/de3c6652-ff9b-3fc6-ac1b-3676bd389b23.gif" alt="" width="556" height="262" />
								</span>
						</span>
				</p>
				<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 18pt; text-indent: 0cm; text-align: center;">
						<span style="font-size: x-small;">
								<span style="font-family: 宋体;">
										<span style="font-size: small;">
												<span style="font-family: 宋体;">图一 jbpm3流程定义对象关系图</span>
										</span>
								</span>
						</span>
				</p>
				<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"> </p>
				<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 18pt; text-indent: 0cm; text-align: left;" align="left">
						<span style="font-size: small;">
								<span style="font-family: 宋体;">从上图我们可以看出这</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">jbpm3</span>
								</span>
								<span style="font-family: 宋体;">中，</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">GraphElement</span>
								</span>
								<span style="font-family: 宋体;">是流程图中所有流程元素的父对象，而整个流程是由</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">ProcessDefinition</span>
								</span>
								<span style="font-family: 宋体;">、</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">Node</span>
								</span>
								<span style="font-family: 宋体;">、</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">Transition</span>
								</span>
								<span style="font-family: 宋体;">三个主要对象构成；</span>
						</span>
				</p>
				<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left">
						<span style="" lang="EN-US">
								<span style="font-family: Calibri; font-size: small;"> <img class="magplus" title="点击查看原始大小图片" src="http://www.javaeye.com/upload/attachment/75909/945ef59e-9462-352f-97b9-e186353826ba.png" alt="" width="760" height="797" /></span>
						</span>
				</p>
				<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;">
						<span style="font-size: small;">
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">
												<span style=""> <span style="font-size: small;"><span style="font-size: x-small;"><span style="" lang="EN-US"><span style="font-family: Calibri;">图二 PVM</span></span><span style="font-family: 宋体;">实体对象关系图</span></span></span>
      </span>
										</span>
								</span>
						</span>
				</p>
				<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"> </p>
				<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;" align="center"> </p>
				<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left">
						<span style="font-size: small;">
								<span style="font-family: 宋体;">从上图可以看出，由于</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">PVM</span>
								</span>
								<span style="font-family: 宋体;">概念的引入，所以在</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">jbpm3</span>
								</span>
								<span style="font-family: 宋体;">中的</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">Graph</span>
								</span>
								<span style="font-family: 宋体;">包在</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">jbpm4</span>
								</span>
								<span style="font-family: 宋体;">中被移除了。在</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">pvm</span>
								</span>
								<span style="font-family: 宋体;">中，在设计期，所有节点元素的父类为</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">ProcessElementImpl</span>
								</span>
								<span style="font-family: 宋体;">，流程的主要组成元素</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">Nodelmpl</span>
								</span>
								<span style="font-family: 宋体;">、</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">TransitionImpl</span>
								</span>
								<span style="font-family: 宋体;">、</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">ProcessDefinitionImpl</span>
								</span>
								<span style="font-family: 宋体;">、</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">EventImpl</span>
								</span>
								<span style="font-family: 宋体;">则都直接或间接继承自</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">ProcessElementImpl</span>
								</span>
								<span style="font-family: 宋体;">。在运行期：</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">jbpm4</span>
								</span>
								<span style="font-family: 宋体;">把流程的运行期行为定义为执行行为（</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">ExecutionImpl</span>
								</span>
								<span style="font-family: 宋体;">）及原子操作行为（</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">AtomicOperation</span>
								</span>
								<span style="font-family: 宋体;">，其具体实现为</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">ExecuteNode</span>
								</span>
								<span style="font-family: 宋体;">、</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">ProceedToDestination</span>
								</span>
								<span style="font-family: 宋体;">、</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">TakeTranstion</span>
								</span>
								<span style="font-family: 宋体;">、</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">MoveToParentNode</span>
								</span>
								<span style="font-family: 宋体;">、</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">MoveToChildNode</span>
								</span>
								<span style="font-family: 宋体;">、</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">signal</span>
								</span>
								<span style="font-family: 宋体;">），其中</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">ExecutionImpl</span>
								</span>
								<span style="font-family: 宋体;">是流程实例、活动实例、事件监听器的所有执行期行为的实现类。</span>
						</span>
				</p>
				<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left">
						<span style="font-size: small;">
								<span style="" lang="EN-US">
										<img class="magplus" title="点击查看原始大小图片" src="http://www.javaeye.com/upload/attachment/75917/fd92ee88-654f-3e2e-804d-67cb891ba813.png" alt="" width="760" height="567" />
								</span>
						</span>
				</p>
				<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"> </p>
				<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;" align="center">
						<span style="font-size: small;">
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">图三 jpdl</span>
								</span>
								<span style="font-family: 宋体;">运行期活动实体对象关系图</span>
						</span>
				</p>
				<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left">
						<span style="" lang="EN-US">
								<span style="font-family: Calibri; font-size: small;"> </span>
						</span>
						<span style="font-size: small;">
								<span style="font-family: 宋体;">上图是</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">jbpm4</span>
								</span>
								<span style="font-family: 宋体;">在运行期的活动实例对象关系图，从图中我们可以看出，在运行期，</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">jbpm4</span>
								</span>
								<span style="font-family: 宋体;">中定义了两个活动接口</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">Activity</span>
								</span>
								<span style="font-family: 宋体;">和</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">ExternalActivity</span>
								</span>
								<span style="font-family: 宋体;">，其中</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">ExternalActivity</span>
								</span>
								<span style="font-family: 宋体;">继承自</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">Activity</span>
								</span>
								<span style="font-family: 宋体;">。</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">Activity</span>
								</span>
								<span style="font-family: 宋体;">是所有自动活动节点的父接口，其实现类为</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">JpdlActivity</span>
								</span>
								<span style="font-family: 宋体;">，而</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">JpdlActivity</span>
								</span>
								<span style="font-family: 宋体;">又衍生出了、</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">StartActivity</span>
								</span>
								<span style="font-family: 宋体;">、</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">JoinActivity</span>
								</span>
								<span style="font-family: 宋体;">、</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">ForkActivity</span>
								</span>
								<span style="font-family: 宋体;">、</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">EndActivity</span>
								</span>
								<span style="font-family: 宋体;">、</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">CreateTimerActivity</span>
								</span>
								<span style="font-family: 宋体;">、</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">JavaActivity</span>
								</span>
								<span style="font-family: 宋体;">、</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">EsbActivity</span>
								</span>
								<span style="font-family: 宋体;">等实例活动对象。而</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">ExternalActivity</span>
								</span>
								<span style="font-family: 宋体;">是具有等待状态的活动（</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">StateActivity</span>
								</span>
								<span style="font-family: 宋体;">）父接口，像人工活动</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">TaskActivity</span>
								</span>
								<span style="font-family: 宋体;">就是实现了此接口。</span>
						</span>
				</p>
				<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left">
						<span style="" lang="EN-US">
								<span style="font-family: Calibri; font-size: small;"> </span>
						</span>
						<span style="" lang="EN-US">
								<span style="">
										<span style="font-family: Calibri; font-size: small;">2、</span>
										<span style="font-family: 'Times New Roman';">  </span>
								</span>
						</span>
						<span style="font-size: small;">
								<span style="font-family: 宋体;">核心引擎的调度算法</span>
						</span>
				</p>
				<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left">
						<span style="font-size: small;">
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">Jbpm3</span>
								</span>
								<span style="font-family: 宋体;">的核心调度算法是基于</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">Token</span>
								</span>
								<span style="font-family: 宋体;">机制的，在运行期这个</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">Token</span>
								</span>
								<span style="font-family: 宋体;">在</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">Node Instance</span>
								</span>
								<span style="font-family: 宋体;">之间流转，依靠</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">Token</span>
								</span>
								<span style="font-family: 宋体;">的触发来推进流程。具体的调度机制，可参加胡长城的文章（</span>
								<span style="" lang="EN-US">
										<a href="http://blog.csdn.net/james999/archive/2007/09/02/1769592.aspx">
												<span style="font-family: Calibri; color: rgb(128, 0, 128);">http://blog.csdn.net/james999/archive/2007/09/02/1769592.aspx</span>
										</a>
								</span>
								<span style="font-family: 宋体;">）；其实这个</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">Token</span>
								</span>
								<span style="font-family: 宋体;">来自于</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">Pertri-net</span>
								</span>
								<span style="font-family: 宋体;">，感兴趣的读者可以去看</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">Pertri-net</span>
								</span>
								<span style="font-family: 宋体;">中的</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">Token</span>
								</span>
								<span style="font-family: 宋体;">及</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">Place</span>
								</span>
								<span style="font-family: 宋体;">。</span>
						</span>
				</p>
				<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;">
						<span style="" lang="EN-US">
								<span style="font-family: Calibri; font-size: small;">
										<img class="magplus" title="点击查看原始大小图片" src="http://www.javaeye.com/upload/attachment/75920/c394c2ba-4994-3a41-bb5d-da3aefaad52a.png" alt="" width="760" height="539" />
 </span>
						</span>
				</p>
				<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;">
						<span style="" lang="EN-US">
								<span style="font-family: Calibri; font-size: small;">
										<span style="font-size: small;">
												<span style="" lang="EN-US">
														<span style="font-family: Calibri;">
																<span style="font-size: x-small;">图四 jbpm3引擎调度图</span>
														</span>
												</span>
										</span>
								</span>
						</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri; font-size: small;"> </span>
						</span>
				</p>
				<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left">
						<span style="font-size: small;">
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">Jbpm4</span>
								</span>
								<span style="font-family: 宋体;">则去掉了</span>
								<span style="" lang="EN-US">
										<span style="font-family: Calibri;">Token</span>
								</span>
								<span style="font-family: 宋体;">，那么它的核心调度机制是怎样实现的呢？</span>
						</span>
				</p>
				<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left">
						<a href="http://www.javaeye.com/upload/attachment/75939/e4bec602-bf0e-3c82-a5b5-9a366ebf4225.png">
								<img class="magplus" title="点击查看原始大小图片" src="http://www.javaeye.com/upload/attachment/75939/e4bec602-bf0e-3c82-a5b5-9a366ebf4225.png" alt="" width="760" height="393" />
						</a>
				</p>
				<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;">
						<span style="" lang="EN-US">
								<span style="font-family: Calibri; font-size: small;"> <span style="" lang="EN-US"><span style="font-family: Calibri; font-size: small;"><span style="font-size: x-small;">图五 jbpm4流程启动序列图</span></span></span></span>
						</span>
				</p>
				<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;">
						<a href="http://www.javaeye.com/upload/attachment/75940/b3827a55-277e-322b-b8ab-500ddc2d6c5b.png">
								<img class="magplus" title="点击查看原始大小图片" src="http://www.javaeye.com/upload/attachment/75940/b3827a55-277e-322b-b8ab-500ddc2d6c5b.png" alt="" width="760" height="427" />
						</a>
				</p>
				<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;">
						<span style="" lang="EN-US">
								<span style="font-family: Calibri; font-size: x-small;">
										<span style="" lang="EN-US">
												<span style="font-family: Calibri; font-size: small;">
														<span style="font-size: small;">
																<span style="font-family: 宋体;">图六 jbpm4 流程推进序列图</span>
														</span>
												</span>
										</span>
								</span>
						</span>
						<span style="font-size: 10.5pt; font-family: 'Calibri','sans-serif';">
								<br style="page-break-before: always;" />
						</span>
				</p>
		</div>
		<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left">
				<span style="font-size: small;">
						<span style="font-family: 宋体;">图五是在</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">jbpm4</span>
						</span>
						<span style="font-family: 宋体;">中启动一个流程实例的执行序列图，图六是节点推进的执行序列图，从上面两个图中我们可以看到核心的调度是依据</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">Execution</span>
						</span>
						<span style="font-family: 宋体;">的转移来实现的（</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">ExecutionImpl</span>
						</span>
						<span style="font-family: 宋体;">可以是</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">ActivityExecution</span>
						</span>
						<span style="font-family: 宋体;">、</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">ClientProcessInstance</span>
						</span>
						<span style="font-family: 宋体;">、</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">EventListenerExecution</span>
						</span>
						<span style="font-family: 宋体;">的实例），</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">Execution</span>
						</span>
						<span style="font-family: 宋体;">实际上就是取代了</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">Jbpm3</span>
						</span>
						<span style="font-family: 宋体;">中的</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">Token</span>
						</span>
						<span style="font-family: 宋体;">，</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">Execution</span>
						</span>
						<span style="font-family: 宋体;">的转移实际上就是根据状态机的变迁（</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">ActivityExecution</span>
						</span>
						<span style="font-family: 宋体;">、</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">ClientProcessInstance</span>
						</span>
						<span style="font-family: 宋体;">、</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">EventListenerExecution</span>
						</span>
						<span style="font-family: 宋体;">实例之间的切换）加上调用相应的原子操作：</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">ExecuteNode</span>
						</span>
						<span style="font-family: 宋体;">、</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">MoveToChildNode</span>
						</span>
						<span style="font-family: 宋体;">、</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">MoveToParentNode</span>
						</span>
						<span style="font-family: 宋体;">、</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">ProceedToDesitination</span>
						</span>
						<span style="font-family: 宋体;">、</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">Signal</span>
						</span>
						<span style="font-family: 宋体;">、</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">TakeTransition</span>
						</span>
						<span style="font-family: 宋体;">（详见</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">pvm/internal/model/op</span>
						</span>
						<span style="font-family: 宋体;">包下的相关类）来实现的。所以</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">Execution</span>
						</span>
						<span style="font-family: 宋体;">实例的集合及有向图实际上就是运行期的路径。</span>
				</span>
		</p>
		<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left">
				<span style="" lang="EN-US">
						<span style="font-family: Calibri; font-size: small;"> </span>
				</span>
		</p>
		<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 18pt; text-indent: -18pt; text-align: left;" align="left">
				<span style="" lang="EN-US">
						<span style="">
								<span style="font-family: Calibri; font-size: small;">3、</span>
								<span style="font-family: 'Times New Roman';">  </span>
						</span>
				</span>
				<span style="font-size: small;">
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">Event-Action</span>
						</span>
						<span style="font-family: 宋体;">机制的变化</span>
				</span>
		</p>
		<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 18pt; text-indent: 0cm; text-align: left;" align="left">
				<span style="font-size: small;">
						<span style="font-family: 宋体;">在</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">jbpm3</span>
						</span>
						<span style="font-family: 宋体;">中是基于</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">Event-Action</span>
						</span>
						<span style="font-family: 宋体;">机制来实现事件与动作的触发的，但是在</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">jbpm4</span>
						</span>
						<span style="font-family: 宋体;">中则采用观察者模式来触发事件的。所有用户自己定义的动作，全部要实现</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">EventListener</span>
						</span>
						<span style="font-family: 宋体;">接口，这些动作作为监听者（就是事件</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">Event</span>
						</span>
						<span style="font-family: 宋体;">的观察者</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">Observer</span>
						</span>
						<span style="font-family: 宋体;">）注册到相应的流程定义对象上（</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">ProcessElement</span>
						</span>
						<span style="font-family: 宋体;">或者</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">Node</span>
						</span>
						<span style="font-family: 宋体;">），而事件</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">Event</span>
						</span>
						<span style="font-family: 宋体;">则作为被观察的对象（实际上就是</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">Observerable</span>
						</span>
						<span style="font-family: 宋体;">），实际上在</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">jbpm4</span>
						</span>
						<span style="font-family: 宋体;">中专门定义出了一个对象</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">ObservableElementImpl</span>
						</span>
						<span style="font-family: 宋体;">，流程定义中的</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">NodeImpl</span>
						</span>
						<span style="font-family: 宋体;">、</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">TransitionImpl</span>
						</span>
						<span style="font-family: 宋体;">、</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">ProcessDefinitionImpl</span>
						</span>
						<span style="font-family: 宋体;">均继承自此对象，因此这些元素本身就可以作为</span>
						<span style="" lang="EN-US">
								<span style="font-family: Calibri;">Observerable</span>
						</span>
						<span style="font-family: 宋体;">而被观察者来监控。</span>
				</span>
		</p>
		<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 18pt; text-indent: -18pt; text-align: left;" align="left">
				<span style="" lang="EN-US">
						<span style="">
								<span style="font-family: Calibri; font-size: small;">4、</span>
								<span style="font-family: 'Times New Roman';">  </span>
						</span>
				</span>
				<span style="font-size: small;">
						<span style="font-family: 宋体;">客户端接口的变化</span>
				</span>
		</p>
		<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 18pt; text-indent: 0cm; text-align: left;" align="left">
				<span style="font-family: 宋体; font-size: 13px;">
				</span>
		</p>
		<p class="MsoListParagraph" style="margin-left: 18pt; text-align: left; text-indent: 0cm;" align="left">
				<span style="font-family: 宋体;">在</span>
				<span style="" lang="EN-US">jbpm4</span>
				<span style="font-family: 宋体;">中对客户端的接口统一为</span>
				<span style="" lang="EN-US">7</span>
				<span style="font-family: 宋体;">个服务接口：</span>
				<span style="" lang="EN-US">ProcessService</span>
				<span style="font-family: 宋体;">、</span>
				<span style="" lang="EN-US">ExecutionService</span>
				<span style="font-family: 宋体;">、</span>
				<span style="" lang="EN-US">CommandService </span>
				<span style="font-family: 宋体;">、</span>
				<span style="" lang="EN-US">TaskService </span>
				<span style="font-family: 宋体;">、</span>
				<span style="" lang="EN-US">ManagementService</span>
				<span style="font-family: 宋体;">、</span>
				<span>
						<span style="font-size: 11pt; color: black;" lang="EN-US">HistoryService</span>
				</span>
				<span>
						<span style="font-size: 11pt; font-family: 宋体; color: black;">、</span>
				</span>
				<span>
						<span style="font-size: 11pt; color: black;" lang="EN-US">IdentityService</span>
				</span>
				<span style="font-family: 宋体;">，这</span>
				<span style="" lang="EN-US">7</span>
				<span style="font-family: 宋体;">个接口可以从</span>
				<span style="" lang="EN-US">ProcessEngine</span>
				<span style="font-family: 宋体;">接口中获得，</span>
				<span style="" lang="EN-US">jbpm4</span>
				<span style="font-family: 宋体;">在启动的过程中由</span>
				<span style="" lang="EN-US">JbpmConfiguration</span>
				<span style="font-family: 宋体;">负责构建引擎。</span>
		</p>
		<p class="MsoListParagraph" style="margin-left: 39pt; text-align: left; text-indent: -21pt;" align="left">
				<span style="font-family: Wingdings;" lang="EN-US">
						<span style="">Ø<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">  </span></span>
				</span>
				<span style="" lang="EN-US">ProcessService-</span>
				<span style="font-family: 宋体;">流程定义的服务接口，包括对流程定义的部署、查询、删除操作；</span>
		</p>
		<p class="MsoListParagraph" style="margin-left: 39pt; text-align: left; text-indent: -21pt;" align="left">
				<span style="font-family: Wingdings;" lang="EN-US">
						<span style="">Ø<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">  </span></span>
				</span>
				<span style="" lang="EN-US">ExecutionService-</span>
				<span style="font-family: 宋体;">执行服务接口，包括启动流程、实例推进、设置变量等操作；</span>
		</p>
		<p class="MsoListParagraph" style="margin-left: 39pt; text-align: left; text-indent: -21pt;" align="left">
				<span style="font-family: Wingdings;" lang="EN-US">
						<span style="">Ø<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">  </span></span>
				</span>
				<span style="" lang="EN-US">CommandService-Command</span>
				<span style="font-family: 宋体;">模式的服务接口，实际上就是将客户端的请求全部封装在一个调用接口中，然后由这个接口去调用</span>
				<span style="" lang="EN-US">Command</span>
				<span style="font-family: 宋体;">接口的众多实现（</span>
				<span style="" lang="EN-US">StartExecutionCmd</span>
				<span style="font-family: 宋体;">、</span>
				<span style="" lang="EN-US">SignalCmd</span>
				<span style="font-family: 宋体;">、</span>
				<span style="" lang="EN-US">SetVariablesCmd</span>
				<span style="font-family: 宋体;">、</span>
				<span style="" lang="EN-US">GetTimersCmd</span>
				<span style="font-family: 宋体;">、</span>
				<span style="" lang="EN-US">DeployCmd</span>
				<span style="font-family: 宋体;">、</span>
				<span style="" lang="EN-US">NewTaskCmd</span>
				<span style="font-family: 宋体;">、</span>
				<span style="" lang="EN-US">SubmitTask</span>
				<span style="font-family: 宋体;">、</span>
				<span style="" lang="EN-US">ExecuteJobCmd</span>
				<span style="font-family: 宋体;">等等，具体可参加</span>
				<span style="" lang="EN-US">pvm/internal/cmd</span>
				<span style="font-family: 宋体;">，</span>
				<span style="" lang="EN-US">task/internal/cmd</span>
				<span style="font-family: 宋体;">包及其它包下实现</span>
				<span style="" lang="EN-US">Command</span>
				<span style="font-family: 宋体;">接口的类），这是典型的</span>
				<span style="" lang="EN-US">Command</span>
				<span style="font-family: 宋体;">模式的应用，感兴趣的读者可以去了解设计模式中的</span>
				<span style="" lang="EN-US">Command</span>
				<span style="font-family: 宋体;">模式；</span>
		</p>
		<p class="MsoListParagraph" style="margin-left: 39pt; text-align: left; text-indent: -21pt;" align="left">
				<span style="font-family: Wingdings;" lang="EN-US">
						<span style="">Ø<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">  </span></span>
				</span>
				<span style="" lang="EN-US">TaskService-</span>
				<span style="font-family: 宋体;">人工活动的服务接口，包括对任务的创建、提交、查询、保存、删除等操作；</span>
		</p>
		<p class="MsoListParagraph" style="margin-left: 39pt; text-align: left; text-indent: -21pt;" align="left">
				<span style="font-family: Wingdings;" lang="EN-US">
						<span style="">Ø<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">  </span></span>
				</span>
				<span style="font-family: 宋体;" lang="EN-US">ManagementService-web</span>
				<span style="font-family: 宋体;">管理控制台的服务接口，目前只有获得消息及计时器的接口实现；</span>
		</p>
		<p class="MsoListParagraph" style="margin-left: 39pt; text-align: left; text-indent: -21pt;" align="left">
				<span>
						<span style="font-family: Wingdings;" lang="EN-US">
								<span style="">Ø<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">  </span></span>
						</span>
				</span>
				<span>
						<span style="font-family: 宋体; color: black;" lang="EN-US">HistoryService-</span>
				</span>
				<span>
						<span style="font-family: 宋体; color: black;">目前有对历史库中的流程实例、活动实例进行查询、某个流程定义中的所有活动的平均持续时间、某个流程定义中的某个活动实例的转移的执行次数</span>
				</span>
				<span>
				</span>
		</p>
		<p class="MsoListParagraph" style="margin-left: 39pt; text-align: left; text-indent: -21pt;" align="left">
				<span>
						<span style="font-family: Wingdings;" lang="EN-US">
								<span style="">Ø<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">  </span></span>
						</span>
				</span>
				<span>
						<span style="font-family: 宋体; color: black;" lang="EN-US">IdentityService-</span>
				</span>
				<span>
						<span style="font-family: 宋体; color: black;">用户、组、成员关系的相关操作方法</span>
				</span>
		</p>
		<p class="MsoListParagraph" style="margin-left: 39pt; text-align: left; text-indent: -21pt;" align="left"> </p>
		<p class="MsoListParagraph" style="margin-left: 18pt; text-align: left; text-indent: -18pt;" align="left">
				<span style="font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: black;" lang="EN-US">
						<span style="">5、<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"></span></span>
				</span>
				<span style="font-family: 宋体; color: black;">历史库的加入</span>
				<span style="font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: black;" lang="EN-US">
				</span>
		</p>
		<p>
				<span style="font-size: 10.5pt; font-family: 宋体; color: black;" lang="EN-US">
						<span style="font-size: small;">jBPM3</span>
				</span>
				<span style="font-size: 10.5pt; font-family: 宋体; color: black;">
						<span style="font-size: small;">中数据库设计一直是我比较诟病的地方，尤其是其实例数据库没有设计历史库的概念并按照办结状态将运行结束的实例数据归入历史库，在这种情况下它的实例数据库就会随着时间而无限膨胀，这就阻碍了它的真实应用，而在</span>
						<span lang="EN-US">
								<span style="font-size: small;">jBPM4</span>
						</span>
						<span style="font-size: small;">的最新代码中（注意</span>
						<span lang="EN-US">
								<span style="font-size: small;">Alpha1</span>
						</span>
						<span style="font-size: small;">还没有出现），历史库的相关功能代码竟然出现了！详见</span>
				</span>
				<span style="font-size: 10.5pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: black;" lang="EN-US">
						<span style="font-size: small;">ExecutionImpl</span>
				</span>
				<span style="font-size: 10.5pt; font-family: 宋体; color: black;">
						<span style="font-size: small;">最新代码中的</span>
				</span>
				<span style="font-size: 10.5pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: black;" lang="EN-US">
						<span style="font-size: small;">fireHistoryEvent</span>
				</span>
				<span style="font-size: 10.5pt; font-family: 宋体; color: black;">
						<span style="font-size: small;">方法及一系列的</span>
				</span>
				<span style="font-size: 10.5pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: black;" lang="EN-US">
						<span style="font-size: small;">historyXXX</span>
				</span>
				<span style="font-size: 10.5pt; font-family: 宋体; color: black;">
						<span style="font-size: small;">方法。在</span>
				</span>
				<span style="font-size: 10.5pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: black;" lang="EN-US">
						<span style="font-size: small;">ActivityBehaviour</span>
				</span>
				<span style="font-size: 10.5pt; font-family: 宋体; color: black;">
						<span style="font-size: small;">的</span>
				</span>
				<span style="font-size: 10.5pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: black;" lang="EN-US">
						<span style="font-size: small;">execute</span>
				</span>
				<span style="font-size: 10.5pt; font-family: 宋体; color: black;">
						<span style="font-size: small;">方法中加入了</span>
				</span>
				<span style="font-size: 10.5pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: black;" lang="EN-US">
						<span style="font-size: small;">historyTaskStart</span>
				</span>
				<span style="font-size: 10.5pt; font-family: 宋体; color: black;">
						<span style="font-size: small;">方法的调用、</span>
				</span>
				<span style="font-size: 10.5pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: black;" lang="EN-US">
						<span style="font-size: small;">signal</span>
				</span>
				<span style="font-size: 10.5pt; font-family: 宋体; color: black;">
						<span style="font-size: small;">方法中加入了</span>
				</span>
				<span style="font-size: 10.5pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: black;" lang="EN-US">
						<span style="font-size: small;">historyTaskEnd</span>
				</span>
				<span style="font-size: 10.5pt; font-family: 宋体; color: black;">
						<span style="font-size: small;">方法的调用，而以上</span>
				</span>
				<span style="font-size: 10.5pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: black;" lang="EN-US">
						<span style="font-size: small;">2</span>
				</span>
				<span style="font-size: 10.5pt; font-family: 宋体; color: black;">
						<span style="font-size: small;">个方法在</span>
				</span>
				<span style="font-size: 10.5pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: black;" lang="EN-US">
						<span style="font-size: small;">ExecutionImpl</span>
				</span>
				<span style="font-size: 10.5pt; font-family: 宋体; color: black;">
						<span style="font-size: small;">中都是以历史事件（</span>
						<span lang="EN-US">
								<span style="font-size: small;">HistoryEvent</span>
						</span>
						<span style="font-size: small;">有</span>
						<span lang="EN-US">
								<span style="font-size: small;">4</span>
						</span>
						<span style="font-size: small;">个实现子类</span>
						<span lang="EN-US">
								<span style="font-size: small;">ProcessInstanceStart</span>
						</span>
						<span style="font-size: small;">、</span>
						<span lang="EN-US">
								<span style="font-size: small;">ProcessInstanceEnd</span>
						</span>
						<span style="font-size: small;">、</span>
						<span lang="EN-US">
								<span style="font-size: small;">ActivityStart</span>
						</span>
						<span style="font-size: small;">、</span>
						<span lang="EN-US">
								<span style="font-size: small;">ActivityEnd</span>
						</span>
						<span style="font-size: small;">分别用作流程实例的创建结束期、活动实例的创建结束期的历史数据处理）的触发机制来实现的，也就是在整个流程实例执行的过程中，都加入了对将运行数据存入历史库的历史事件（</span>
						<span lang="EN-US">
								<span style="font-size: small;">HistoryEvent</span>
						</span>
						<span style="font-size: small;">）的触发。这样实例列表的查询可以只查询历史库。不过这里很遗憾的是，这个事件没有同时清除运行库的数据，这样还是会造成运行库的无限膨胀问题。</span>
				</span>
		</p>
<img src ="http://www.blogjava.net/libin2722/aggbug/286513.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/libin2722/" target="_blank">礼物</a> 2009-07-13 10:18 <a href="http://www.blogjava.net/libin2722/articles/286513.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>