﻿<?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-落叶归根-文章分类-jBPM</title><link>http://www.blogjava.net/allan-oy/category/5433.html</link><description>一个人首先要尊重别人，然后才能得到别人的尊重；一个人首先要对自己负责，然后才有资格去对别人负责。</description><language>zh-cn</language><lastBuildDate>Tue, 27 Feb 2007 16:19:12 GMT</lastBuildDate><pubDate>Tue, 27 Feb 2007 16:19:12 GMT</pubDate><ttl>60</ttl><item><title>jBPM的令牌/信令技术(转载）</title><link>http://www.blogjava.net/allan-oy/articles/22268.html</link><dc:creator>落叶归根</dc:creator><author>落叶归根</author><pubDate>Fri, 02 Dec 2005 09:23:00 GMT</pubDate><guid>http://www.blogjava.net/allan-oy/articles/22268.html</guid><wfw:comment>http://www.blogjava.net/allan-oy/comments/22268.html</wfw:comment><comments>http://www.blogjava.net/allan-oy/articles/22268.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/allan-oy/comments/commentRss/22268.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/allan-oy/services/trackbacks/22268.html</trackback:ping><description><![CDATA[<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">jbpm</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">中最重要的概念</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">,</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">应该是令牌</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">(Token)</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">和信令</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">(Signal)</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">技术</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">,</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">这个在计算机网络中到处可见</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体"><BR></SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">的技术</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">,</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">在工作流引擎中也大放异彩</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">.<BR></SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">我们看如下代码</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">:<BR>//pd</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">是</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">process definition,pi</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">是</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">process instance<BR>ProcessInstance pi = new ProcessInstance( pd );<BR>//</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">启动流程</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体"><BR>pi.start();<BR>//</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">得到根令牌</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体"><BR>Token token = pi.getRootToken();<BR>//</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">发信令</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体"><BR>token.signal();<BR>Token</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">的</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">signal</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">方法也可以传入</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">transition</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">参数</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">,</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">这个方法把信令发送给</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">Token,</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">这样</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">,</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">令牌将被</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体"><BR></SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">激活</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">,</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">并沿指定的</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">transition</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">离开当前的状态</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">(</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">如果没有指定</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">transition,</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">将沿缺省的</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">transition<BR></SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">离开当前状态</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">).<BR>jbpm</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">是怎么实现的呢</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">?</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">其实很简单</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">:<BR>1)Token</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">记录了当前的状态</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">,</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">只有当前的状态</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">(</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">或称节点</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">)</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">拥有该令牌</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体"><BR>2)</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">向</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">TOKEN</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">发</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">signal</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">后</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">,</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">当前状态收到该</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">signal<BR>3)</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">当前状态把令牌传给</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">signal</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">中指定的</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">transition<BR>4)transition</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">收到令牌后</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">,</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">不强占</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">,</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">马上把令牌传给下个状态</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">.<BR>5)</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">根据令牌的位置</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">,</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">流程的状态已经发生改变</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">.
<SCRIPT language=JavaScript src="/2.js" type=text/javascript>

</SCRIPT>
 </SPAN></P><img src ="http://www.blogjava.net/allan-oy/aggbug/22268.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/allan-oy/" target="_blank">落叶归根</a> 2005-12-02 17:23 <a href="http://www.blogjava.net/allan-oy/articles/22268.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>jbpm任务分配管理</title><link>http://www.blogjava.net/allan-oy/articles/22259.html</link><dc:creator>落叶归根</dc:creator><author>落叶归根</author><pubDate>Fri, 02 Dec 2005 08:39:00 GMT</pubDate><guid>http://www.blogjava.net/allan-oy/articles/22259.html</guid><wfw:comment>http://www.blogjava.net/allan-oy/comments/22259.html</wfw:comment><comments>http://www.blogjava.net/allan-oy/articles/22259.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/allan-oy/comments/commentRss/22259.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/allan-oy/services/trackbacks/22259.html</trackback:ping><description><![CDATA[<SPAN id=LblContent>&nbsp;
<P>一个Task instance（任务实例）可以被分配给一个actorId (java.lang.String)。所有的Task instance都被保存在数据库中的表jbpm_taskinstance里。当你想得到特定用户的任务清单时，你就可以通过一个与用户关联的actorId来查询这张表。</P>
<P>一个流程定义有一个TaskMgmtDefinition；一个TaskMgmtDefinition对应多个swimlane,同时对应多个task;一个swimlane有多个task,可以&nbsp; TaskMgmtDefinition中通过task的名称直接获取相应的task;</P>
<P>swimlane对象有四个属性，分别是name（名字）、assignmentDelegation（分配代理类）、taskMgmtDefinition、tasks（Set 对应多个task),可以增加task</P>
<P>task对象主要的属性：taskMgmtDefinition、swimlane、assignmentDelegation、taskNode，需要注意的是swimlane和assignmentDelegation中间只是可以一个属性有值，因为它们都和任务的分配有关系。</P>
<P>一个流程实例有一个TaskMgmtInstance；一个TaskMgmtInstance对应多个swimlaneInstance,同时对应多个taskInstance;一个swimlaneInstance有多个taskInstance,可以从TaskMgmtInstance中直接获取相应的taskInstance;</P>
<P>swimlaneInstance对象主要有五个属性，分别是name、actorId、pooledActors（Set）、swimlane、taskMgmtInstance。<BR>taskInstance对象的主要属性：name、actorId、task、swimlaneInstance、taskMgmtInstance、pooledActors。</P>
<P>当对任务进行分配时，一般需要实现AssignmentHandler这个接口，这个接口的方法只有一个：<BR>&nbsp; void assign( Assignable assignable, ExecutionContext executionContext ) throws Exception;<BR>一个典型的实现（把名字是'change nappy'的任务交给NappyAssignmentHandler这个类来分配）<BR>&nbsp;&nbsp; &lt;task name='change nappy'&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;assignment class='org.jbpm.tutorial.taskmgmt.NappyAssignmentHandler' /&gt;<BR>&nbsp;&nbsp; &lt;/task&gt;<BR>NappyAssignmentHandler类：<BR>&nbsp; public void assign(Assignable assignable, ExecutionContext executionContext) {<BR>&nbsp;&nbsp;&nbsp; assignable.setActorId("papa");<BR>&nbsp; }<BR>同样，Assignable只是一个接口，它有两个方法：setActorId()和setPooledActors()，Assignable的具体实现类也是两个<BR>&nbsp; swimlaneInstancehe和taskInstance。这样就不不难理解整个任务分配流程了：<BR>&nbsp; 1、流程进入TaskNode节点，执行TaskNode类的execute()方法，该方法首先获得TaskMgmtInstance实例，然后通过它来创建TaskInstance。taskMgmtInstance.createTaskInstance(task, executionContext);<BR>&nbsp; 2、在上面的createTaskInstance(task, executionContext)里，该方法调用了taskInstance.assign(executionContext)对taskInstance进行分配。<BR>&nbsp; 3、在assign(executionContext)方法里，首先会判断task属性里是否存在swimlane，如果有的话，这个taskInstance就会分配给swimlane指定的ActorId或 PooledActors；如果不存在，再去找task属性里 assignmentDelegation（分配代理类）通过代理类（即我们自己写的实现AssignmentHandler这个接口的类）指定ActorId或 PooledActors。</P></SPAN><img src ="http://www.blogjava.net/allan-oy/aggbug/22259.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/allan-oy/" target="_blank">落叶归根</a> 2005-12-02 16:39 <a href="http://www.blogjava.net/allan-oy/articles/22259.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>jbpm的流程模型</title><link>http://www.blogjava.net/allan-oy/articles/22216.html</link><dc:creator>落叶归根</dc:creator><author>落叶归根</author><pubDate>Fri, 02 Dec 2005 03:42:00 GMT</pubDate><guid>http://www.blogjava.net/allan-oy/articles/22216.html</guid><wfw:comment>http://www.blogjava.net/allan-oy/comments/22216.html</wfw:comment><comments>http://www.blogjava.net/allan-oy/articles/22216.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/allan-oy/comments/commentRss/22216.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/allan-oy/services/trackbacks/22216.html</trackback:ping><description><![CDATA[<SPAN id=LblContent><STRONG><FONT size=5>jbpm的流程模型(转载）</FONT><BR><BR>1、process definition<BR></STRONG>&nbsp;&nbsp; 一个process definition代表了一个正式的业务流程，它以一个流程图为基础。这个流程图由&nbsp; 许多node和transition组成。每个node在这个流程图里都有着各自特殊的类型，这些不同的类型决定了node在运行时的不同行为。一个process definition只有一个start state 。<BR><STRONG>2、token</STRONG><BR>&nbsp;&nbsp; 一个token代表了一条执行路径，它包含了这条执行路径的当前的执行状态（current state）。 <BR><STRONG>3、process instance<BR></STRONG>&nbsp;&nbsp; 一个process instance（流程实例）即一个process definition（流程定义）的流程执行实例。一个process definition可以对应多个process instance。当一个process instance被创建的时候，一个主执行路径token同时被创建，这个token叫做root token，它指向流程定义的start state（processDefinition.getStartState()==token.getNode()）。<BR><STRONG>4、signal <BR></STRONG>&nbsp;&nbsp; 一个signal 发送给token通知token 继续流程的执行。如果signal 没有指定transition，token将沿缺省的transition离开当前状态,如果signal 指定transition，token将沿指定的transition离开当前的状态。看源代码可以看到发给process instance的signal 其实都是发送给了root token。 <BR><STRONG>5、Actions</STRONG> <BR>&nbsp;&nbsp; jbpm提供了灵活的action ，当流程执行，token 进入node和transition时，会触发相应的一些event（事件）。在这些event上附上我们自己写的action，就会带动action 的执行。action里是我们自己的相关java操作代码，非常方便。注意的是event（事件）是内置的，无法扩展。另外，action也可以直接挂在node上，而不依赖于event（事件）的触发，这个很重要！<IMG height=1 src="/RongHao/aggbug/19445.html" width=1><BR></SPAN><img src ="http://www.blogjava.net/allan-oy/aggbug/22216.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/allan-oy/" target="_blank">落叶归根</a> 2005-12-02 11:42 <a href="http://www.blogjava.net/allan-oy/articles/22216.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>jbpm简单流程的实现</title><link>http://www.blogjava.net/allan-oy/articles/22151.html</link><dc:creator>落叶归根</dc:creator><author>落叶归根</author><pubDate>Thu, 01 Dec 2005 11:41:00 GMT</pubDate><guid>http://www.blogjava.net/allan-oy/articles/22151.html</guid><wfw:comment>http://www.blogjava.net/allan-oy/comments/22151.html</wfw:comment><comments>http://www.blogjava.net/allan-oy/articles/22151.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/allan-oy/comments/commentRss/22151.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/allan-oy/services/trackbacks/22151.html</trackback:ping><description><![CDATA[<DIV class=postTitle>jbpm简单流程的实现--(转载)</DIV>
<DIV class=postText>
<P>看了3天JBPM中与在群里兄弟的帮助下简单运行了一条流程,把自己的一点心得写出来留做纪念:</P>
<P>使用JBPM3是需要注意的几个小问题:</P>
<P>1)在使用jbpm-db-3.0.zip包中自带的ANT脚本来生成各种数据库脚本的时候,JDK的版本需要是5.0否则报不支持的功能错误!</P>
<P>2)在JBMP3上面执行的流程定义一定是符合3.0规范的,2.0与3.0的JPDL文件有比较大的差别!</P>
<P>我就是疏忽了这点导致白忙活了一天!</P>
<P>简单的请假流程(JPDL):</P>
<P>&lt;?xml version="1.0" encoding="UTF-8"?&gt;</P>
<P>&lt;process-definition <BR>&nbsp; xmlns="<A href="http://jbpm.org/3/jpdl">http://jbpm.org/3/jpdl</A>"<BR>&nbsp; xmlns:xsi="<A href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</A>"<BR>&nbsp; xsi:schemaLocation="<A href="http://jbpm.org/3/jpdl">http://jbpm.org/3/jpdl</A> <A href="http://jbpm.org/xsd/jpdl-3.0.xsd">http://jbpm.org/xsd/jpdl-3.0.xsd</A>"<BR>&nbsp; name="leave process1"&gt;<BR>&nbsp;<BR>&nbsp;&lt;start-state name="start"&gt;<BR>&nbsp;&nbsp;&lt;transition to="leave draft"/&gt;<BR>&nbsp;&lt;/start-state&gt;<BR>&nbsp;<BR>&nbsp;&lt;swimlane name="chief"&gt;<BR>&nbsp;&nbsp;&lt;assignment class="com.starocean.jbpm.swimlane.leaveprocess.ChiefHandler"/&gt;<BR>&nbsp;&lt;/swimlane&gt;&nbsp; &nbsp;</P>
<P>&nbsp;&lt;swimlane name="boss"&gt;<BR>&nbsp;&nbsp;&lt;assignment class="com.starocean.jbpm.swimlane.leaveprocess.BossHandler"/&gt;<BR>&nbsp;&lt;/swimlane&gt;<BR>&nbsp;<BR>&nbsp;&lt;state name="leave draft"&gt;<BR>&nbsp;&nbsp;&lt;transition to="isChief"/&gt;<BR>&nbsp;&lt;/state&gt;<BR>&nbsp;<BR>&nbsp;&lt;decision name="isChief"&gt;<BR>&nbsp;&nbsp;&lt;handler class="com.starocean.jbpm.swimlane.leaveprocess.IsChiefHandler"/&gt;<BR>&nbsp;&nbsp;&lt;transition to="chief auditing" name="notchief"/&gt;<BR>&nbsp;&nbsp;&lt;transition to="boss auditing" name="ischief"/&gt;<BR>&nbsp;&lt;/decision&gt;<BR>&nbsp;<BR>&nbsp;&lt;task-node name="chief auditing"&gt;<BR>&nbsp;&nbsp;&lt;task name="ca" swimlane="chief"/&gt;<BR>&nbsp;&nbsp;&lt;transition to="boss auditing"/&gt;<BR>&nbsp;&lt;/task-node&gt;<BR>&nbsp;<BR>&nbsp;&lt;task-node name="boss auditing"&gt;<BR>&nbsp;&nbsp;&lt;task name="ba" swimlane="boss"/&gt;<BR>&nbsp;&nbsp;&lt;transition to="end"/&gt;<BR>&nbsp;&lt;/task-node&gt;</P>
<P>&nbsp;&lt;end-state name="end"/&gt;<BR>&nbsp;<BR>&lt;/process-definition&gt;</P>
<P>这个JPDL主要表达的意思是一个3步的请假流程:</P>
<P>1)请假人起草请假单,送交部门领导处理,然后送公司领导处理</P>
<P>2)如果请假人是部门领导那直接转到公司领导处理</P>
<P>里面没有回退等环节,后面陆续加上</P>
<P></P>
<P>首先定义了两个 SWIMLANE:<FONT color=#ff0000>chief&amp;boss</FONT>,用来定义两个角色:</P>
<P>public class BossHandler implements AssignmentHandler {</P>
<P>&nbsp;private static final long serialVersionUID = -995603186672306606L;<BR>&nbsp;<BR>&nbsp;private static final Log log = LogFactory.getLog(ChiefHandler.class);<BR>&nbsp;&nbsp; <BR>&nbsp;public void assign(Assignable arg0, ExecutionContext arg1) throws Exception {<BR>&nbsp;&nbsp;log.debug("BossHandler start");<BR>&nbsp;&nbsp;arg0.setActorId("boss");<BR>&nbsp;&nbsp;log.debug("BossHandler end");<BR>&nbsp;}</P>
<P>}</P>
<P>对请求者身份来做验证,如果是不门领导请假就直接给公司BOSS来处理,普通用户首先要经部门领导审批后</P>
<P>才能带公司BOSS:</P>
<P>&nbsp;&lt;decision name="isChief"&gt;<BR>&nbsp;&nbsp;&lt;handler class="com.starocean.jbpm.swimlane.leaveprocess.IsChiefHandler"/&gt;<BR>&nbsp;&nbsp;&lt;transition to="chief auditing" name="notchief"/&gt;<BR>&nbsp;&nbsp;&lt;transition to="boss auditing" name="ischief"/&gt;<BR>&nbsp;&lt;/decision&gt;</P>
<P>public class IsChiefHandler implements DecisionHandler {</P>
<P>&nbsp;private static final long serialVersionUID = -6311809219060093239L;</P>
<P>&nbsp;private static final Log log = LogFactory.getLog(IsChiefHandler.class);<BR>&nbsp;<BR>&nbsp;public String decide(ExecutionContext arg0) throws Exception {<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;log.debug("IsChiefHandler start");<BR>&nbsp;&nbsp;if(arg0.getVariable("userName").equals("snake")){<BR>&nbsp;&nbsp;&nbsp;log.debug("IsChiefHandler end");<BR>&nbsp;&nbsp;&nbsp;return "ischief";<BR>&nbsp;&nbsp;}else{<BR>&nbsp;&nbsp;&nbsp;log.debug("IsChiefHandler end");<BR>&nbsp;&nbsp;&nbsp;return "notchief";<BR>&nbsp;&nbsp;}<BR>&nbsp;}</P>
<P>}</P>
<P>做了个接口,负责页面层也工作流引擎交互</P>
<P>public class WorkFlowAPI {<BR>&nbsp;<BR>&nbsp;private static final Log log = LogFactory.getLog(WorkFlowAPI.class);<BR>&nbsp;<BR>&nbsp;private static JbpmSessionFactory jbpmSessionFactory = JbpmSessionFactory.buildJbpmSessionFactory();<BR>&nbsp;<BR>&nbsp;&nbsp;<BR>&nbsp;/**<BR>&nbsp; * 取得用户的代办信息<BR>&nbsp; * @param userName&nbsp;用户名称<BR>&nbsp; * @return&nbsp;&nbsp;&nbsp;代办工作列表<BR>&nbsp; */<BR>&nbsp;public List getPendingJob(String userName){<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;log.debug("getPendingJob start");<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;JbpmSession session = jbpmSessionFactory.openJbpmSession();<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;log.debug("getPendingJob end");</P>
<P>&nbsp;&nbsp;return session.getTaskMgmtSession().findTaskInstances(userName);<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;<BR>&nbsp;}<BR>&nbsp;</P>
<P>这是我任务比较重要的一个方法,他手工的使流程想下一个环节流转:<BR>&nbsp;/**<BR>&nbsp; * 将指定流程向下一步流转<BR>&nbsp; * @param wfid&nbsp;&nbsp;工作流实例编号<BR>&nbsp; * @param userName&nbsp;操作者名称<BR>&nbsp; */<BR>&nbsp;public void todoNext(long wfid,String userName){<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;log.debug("todoNext start"+wfid);<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;JbpmSession session = jbpmSessionFactory.openJbpmSession();<BR>&nbsp;&nbsp;session.beginTransaction();<BR>&nbsp;&nbsp;GraphSession gSession = session.getGraphSession();<BR>&nbsp;&nbsp;ProcessInstance pi = gSession.loadProcessInstance(wfid);<BR>&nbsp;&nbsp;取得用户的TASK<BR>&nbsp;&nbsp;List list = session.getTaskMgmtSession().findTaskInstances(userName);<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;log.debug(" process instance size = "+list.size());<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;if(list.size() &gt; 0){<BR>&nbsp;&nbsp;&nbsp;Iterator ite = list.iterator();<BR>&nbsp;&nbsp;&nbsp;while(ite.hasNext()){<BR>&nbsp;&nbsp;&nbsp;&nbsp;TaskInstance ti = (TaskInstance)ite.next();<BR>&nbsp;&nbsp;&nbsp;&nbsp;log.debug(" user "+userName+" 's task "+ti.getName()+" done!");<BR>&nbsp;&nbsp;&nbsp;&nbsp;if(ti.getActorId().equals(userName) &amp;&amp; ti.getTaskMgmtInstance().getProcessInstance().getId() == wfid)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;执行END()操作后系统回自动执行SIGNAL()操作!所以一旦执行了END就不要在执行SIGNAL了!<BR>&nbsp;&nbsp; ti.end();<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;}else{<BR>&nbsp;&nbsp;&nbsp;pi.signal();<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;gSession.saveProcessInstance(pi);<BR>&nbsp;&nbsp;session.commitTransaction();<BR>&nbsp;&nbsp;session.close();<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;log.debug("todoNext end");<BR>&nbsp;}<BR>&nbsp;<BR>&nbsp;/**<BR>&nbsp; * 保存流程定义<BR>&nbsp; * @param xmlStr&nbsp;流程定义的JPDL的XML字符串形式<BR>&nbsp; */<BR>&nbsp;public void saveWorkFlowDefinition(String xmlStr){<BR>&nbsp;&nbsp;log.debug("saveWorkFlowDefinition start");<BR>&nbsp;&nbsp;ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(xmlStr);<BR>&nbsp;&nbsp;JbpmSession session = jbpmSessionFactory.openJbpmSession();<BR>&nbsp;&nbsp;session.beginTransaction();<BR>&nbsp;&nbsp;session.getGraphSession().saveProcessDefinition(processDefinition);<BR>&nbsp;&nbsp;session.commitTransactionAndClose();<BR>&nbsp;&nbsp;log.debug("saveWorkFlowDefinition end");<BR>&nbsp;}<BR>&nbsp;<BR>&nbsp;/**<BR>&nbsp; * 取得所有的工作流定义<BR>&nbsp; * @return&nbsp;工作流定义列表<BR>&nbsp; */<BR>&nbsp;public List getAllWorkFlow(){<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;log.debug("getAllWorkFlow start");<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;JbpmSession session = jbpmSessionFactory.openJbpmSession();<BR>&nbsp;&nbsp;GraphSession graphSession = session.getGraphSession();<BR>&nbsp;&nbsp;log.debug("getAllWorkFlow end");&nbsp;&nbsp;<BR>&nbsp;&nbsp;return graphSession.findAllProcessDefinitions();<BR>&nbsp;&nbsp;<BR>&nbsp;}<BR>&nbsp;<BR>&nbsp;/**<BR>&nbsp; * 取得指定工作流的可用实例<BR>&nbsp; * @param workFlowName&nbsp;工作流名称<BR>&nbsp; * @return&nbsp;工作流的实例列表<BR>&nbsp; */<BR>&nbsp;public List getAllInstanceOfWorkFlow(String workFlowName){<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;log.debug("getAllInstanceOfWorkFlow start");<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;JbpmSession session = jbpmSessionFactory.openJbpmSession();<BR>&nbsp;&nbsp;GraphSession graphSession = session.getGraphSession();&nbsp;<BR>&nbsp;&nbsp;ProcessDefinition pd = graphSession.findLatestProcessDefinition(workFlowName);&nbsp;&nbsp;<BR>&nbsp;&nbsp;List processInstances = graphSession.findProcessInstances(pd.getId());<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;log.debug("getAllInstanceOfWorkFlow end");&nbsp;&nbsp;<BR>&nbsp;&nbsp;return processInstances;<BR>&nbsp;<BR>&nbsp;}<BR>&nbsp;<BR>&nbsp;/**<BR>&nbsp; * 启动工作流<BR>&nbsp; * @param workFlowName&nbsp;工作流名称（JPDL中的process-definition name='xxx'name属性）<BR>&nbsp; * @param userName&nbsp;&nbsp;用户标识<BR>&nbsp; * @return&nbsp;工作流实例编号<BR>&nbsp; */<BR>&nbsp;public long startWorkFlow(String workFlowName,String userName){<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;log.debug("startworkflow "+workFlowName+" start");<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;long workFlowID = -1;<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;ProcessDefinition processDefinition = null;<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;JbpmSession jbpmSession = jbpmSessionFactory.openJbpmSession();<BR>&nbsp;&nbsp;//启动事务<BR>&nbsp;&nbsp;jbpmSession.beginTransaction();<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;//按照工作流名称自数据库中取得流程定义<BR>&nbsp;&nbsp;processDefinition = jbpmSession.getGraphSession().findLatestProcessDefinition(workFlowName);<BR>&nbsp;&nbsp;//实例化流程定义<BR>&nbsp;&nbsp;ProcessInstance instance = new ProcessInstance(processDefinition);<BR>&nbsp;&nbsp;workFlowID = instance.getId();<BR>&nbsp;&nbsp;//加入流程启动人的信息<BR>&nbsp;&nbsp;instance.getContextInstance().setVariable("userName",userName);<BR>&nbsp;&nbsp;&nbsp;&nbsp; //保存工作流<BR>&nbsp;&nbsp;jbpmSession.getGraphSession().saveProcessInstance(instance);<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp; jbpmSession.commitTransaction();<BR>&nbsp;&nbsp;&nbsp;&nbsp; jbpmSession.close();<BR>&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp; return workFlowID;<BR>&nbsp;}<BR>&nbsp;<BR>}</P>
<P></P>
<P></P>
<P></P><BR><BR>
<P id=TBPingURL>Trackback: <A href="http://blog.csdn.net/snake_liu/archive/2005/10/25/516412.aspx">http://blog.csdn.net/snake_liu/archive/2005/10/25/516412.aspx</A></P></DIV><img src ="http://www.blogjava.net/allan-oy/aggbug/22151.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/allan-oy/" target="_blank">落叶归根</a> 2005-12-01 19:41 <a href="http://www.blogjava.net/allan-oy/articles/22151.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>jbpm的用户角色管理 </title><link>http://www.blogjava.net/allan-oy/articles/21836.html</link><dc:creator>落叶归根</dc:creator><author>落叶归根</author><pubDate>Tue, 29 Nov 2005 08:09:00 GMT</pubDate><guid>http://www.blogjava.net/allan-oy/articles/21836.html</guid><wfw:comment>http://www.blogjava.net/allan-oy/comments/21836.html</wfw:comment><comments>http://www.blogjava.net/allan-oy/articles/21836.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/allan-oy/comments/commentRss/21836.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/allan-oy/services/trackbacks/21836.html</trackback:ping><description><![CDATA[<DIV class=posttitle><A class=posttitle id=_4370d64f09b4058_HomePageDays_DaysList__ctl1_DayItem_DayList__ctl1_TitleUrl HREF="/RongHao/archive/2005/11/16/20121.html">jbpm的用户角色管理 </A></DIV>jbpm在用户角色管理上共设计了四个类：Entity、 Membership、 Group、 User<BR>Entity类是其他三个类的父类，它包含了两个属性：name(String)、 permissions(Set)<BR>User类继承Entity类，包含三个属性：password(String)、 email(String)、 memberships(Set)<BR>Group类继承Entity类，包含四个属性: type(String) 、parent(Group)、 children(Set)、 memberships(Set)<BR>Membership类继承Entity类，包含三个属性:role(String)、 user(User)、 group(Group) <BR>很明显，一个user对应一个用户，一个group对应一个用户组，它们之间通过membership关联，并且一个user可以属于多个不同类型（type)的group，user和 group之间是多对多的关系。<BR>Membership类的role属性个人感觉用途不大，反倒是name属性代表了user在group里的role（角色）！ <img src ="http://www.blogjava.net/allan-oy/aggbug/21836.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/allan-oy/" target="_blank">落叶归根</a> 2005-11-29 16:09 <a href="http://www.blogjava.net/allan-oy/articles/21836.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>