零全零美(www.zzgwt.com)
生活中的很多事情,并不像If...Else那么簡單!
BlogJava
首頁
新文章
聯(lián)系
管理
posts - 96,comments - 52,trackbacks - 0
<
2008年11月
>
日
一
二
三
四
五
六
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
4
5
6
常用鏈接
我的隨筆
我的評論
我的參與
最新評論
隨筆分類
apache組件(4)
JavaScript(14)
jbpm(6)
oracle(5)
PL/SQL(1)
SEO(3)
tomcat(5)
ubuntu(16)
安全相關(26)
數(shù)據(jù)庫
正則表達式(6)
設計模式(3)
隨筆檔案
2012年9月 (1)
2012年7月 (3)
2012年6月 (2)
2009年11月 (36)
2009年10月 (18)
2009年9月 (1)
2009年2月 (1)
2009年1月 (1)
2008年11月 (9)
2008年9月 (1)
2008年8月 (1)
2008年7月 (4)
2008年6月 (2)
2008年5月 (6)
2008年4月 (11)
友情鏈接
www.modaotea.com
茶藝培訓 茶樓管理
www.website371.com
鄭州做網站 鄭州網站建設 鄭州做網站公司 鄭州網站優(yōu)化 鄭州網站制作
河南省大井科技有限公司(www.zzgwt.com)
搜索
積分與排名
積分 - 151393
排名 - 406
最新評論
1.?re: 正則表達式學習筆記(1) 行的開始和結束、字符組、連字符、脫字符、用"."去匹配任意字符
贊
--性感電子
2.?re: Apache httpd+Jk+Tomcat實現(xiàn)JAVA服務器配置全解析(1):基礎環(huán)境搭建
什么嘛,我就是不懂這些才搜索的,我最需要的就是你省略的部分,如何配置安裝,唉,又得繼續(xù)找資料了。
--吐槽
3.?re: JavaScript學習筆記(1)變量的生命周期
寫的很好
--fwd
4.?re: SELinux學習(1):Can't connect to MySQL server on 'ip' (13) 的解決方案
沒玩過這東西啊呵呵
--臺式萬用表
5.?re: [原創(chuàng)]巧用System.getProperty()編譯現(xiàn)有工程的java文件
你不能用ANT嗎?
--DB Compare Tool
[原創(chuàng)]JBPM源碼解讀之:Fork
Fork節(jié)點在整個JBPM流程運轉過程中配合Join使用提供使多于一個的節(jié)點如:TaskNode、State等并行運行的作用,很可惜我們不能利用Fork提供的現(xiàn)有機制實現(xiàn)需求中經常遇到的并發(fā)子流程的效果,當然雖然JBPM并不支持并發(fā)子流程的機制,并不代表我們不能變通的實現(xiàn),我將在另一篇文章中詳細說明
我的并發(fā)子流程的實現(xiàn)方式
。
Fork類的注釋中說:if this fork behaviour is not sufficient for your needs, consider writing your own custom TokenHandler.看來連JBPM開發(fā)小組也意識到Fork可能不能滿足某些特殊的需求。注釋中還說Fork節(jié)點有三種配置方式,我很奇怪為什么代碼中只能找到兩種:
1、without configuration : in that case the fork will launch one new sub-token over each of the leaving tranisions of the fork node.
2、a script : can be used to calculate a collection of transition names at runtime. if a script is configured, the script must have exactly one variable with 'write' access. that variable should be assigned a java.util.Collection in the script expression.
Fork類繼承自Node并實現(xiàn)了Parsable接口。Fork類相對簡單,他的私有成員變量只有一個:
1
/** */
/**
2
* a script that calculates the transitionNames at runtime.
3
*/
4
Script script
=
null
;
Fork中的Script可以在運行時對Fork節(jié)點選擇Transition,所以在實際應用中可以
使用Fork+Script的方式進行多路路由選擇
.但是有一點要特別注意:JBBM User Guide文檔中說:the script in a fork is not persisted. script in fork might be removed in later versions of jPDL,原本以為這句話的前半句是說Script不會被持久化進數(shù)據(jù)庫,實驗了才知道其實Script還是被存進了數(shù)據(jù)庫,這半句的意思應該是說"fork中的script不被堅持",JBPM開發(fā)小組要在新版本中放棄Script,我相信他們一定會提供更好的解決方案,讓我們拭目以待。 Fork重寫了Node類的read(Element forkElement, JpdlXmlReader jpdlReader)方法,其主要作用是解析JPDL中Fork節(jié)點Script的配置,并初始化自己的成員變量script。下面是execute(ExecutionContext executionContext)方法中的相關處理
1
Token token
=
executionContext.getToken();
2
//
聲明離開轉向的集合
3
Collection transitionNames
=
null
;
4
//
聲明子Token容器
5
List forkedTokens
=
new
ArrayList();
6
7
//
如果沒有Script,默認按照其父類Node的getLeavingTransitionsMap取得所有離開轉向
8
if
(script
==
null
)
{
9
transitionNames
=
getLeavingTransitionsMap().keySet();
10
}
else
{
11
//
如果有Script,按照規(guī)范該Script應該返回一個Collection類型的數(shù)據(jù),作為Fork的離開轉向集合
12
Map outputMap
=
null
;
13
try
{
14
//
執(zhí)行Script,得到返回的Collection數(shù)據(jù)
15
outputMap
=
script.eval(token);
16
}
catch
(Exception e)
{
17
this
.raiseException(e, executionContext);
18
}
19
if
(outputMap.size()
==
1
)
{
20
Object result
=
outputMap.values().iterator().next();
21
if
(result
instanceof
Collection)
{
22
transitionNames
=
(Collection) result;
23
}
24
}
25
if
(transitionNames
==
null
)
{
26
throw
new
JbpmException(
"
script for fork '
"
+
name
+
"
' should produce one collection (in one writable variable):
"
+
transitionNames);
27
}
28
}
下面讓我們來看一下,F(xiàn)ork產生的子Token的命名方式:
1
/** */
/**
2
* 功能描述:為子Token取名字<BR>
3
*
@param
parent 父Token
4
*
@param
transitionName 離開轉向的名字
5
*/
6
protected
String getTokenName(Token parent, String transitionName)
{
7
String tokenName
=
null
;
8
//
如果transitionName不為空
9
if
(transitionName
!=
null
)
{
10
//
如果父Tokehn中不存在以transitionName命名的子Token
11
if
(
!
parent.hasChild(transitionName))
{
12
//
以transitionName的名字為子Token命名
13
tokenName
=
transitionName;
14
}
else
{
15
//
如果已經存在則以transitionName+2的方式命名
16
int
i
=
2
;
17
tokenName
=
transitionName
+
Integer.toString(i);
18
//
如果加2之后依然存在,開始循環(huán),直到父Token中不存在相同名稱的子Token
19
while
(parent.hasChild(tokenName))
{
20
i
++
;
21
tokenName
=
transitionName
+
Integer.toString(i);
22
}
23
}
24
}
else
{
25
//
如果transitionName為空,則判但父Token中是否有子Token,如果有則以parent.getChildren().size() + 1法命名,
26
//
如果沒有直接命名為1
27
int
size
=
(parent.getChildren()
!=
null
?
parent.getChildren().size()
+
1
:
1
);
28
tokenName
=
Integer.toString(size);
29
}
30
return
tokenName;
31
}
名字定好之后,F(xiàn)ork為每個離開轉向分別創(chuàng)建了一個子Token,加入一開始創(chuàng)建的forkedTokens中。最后開始循環(huán)列表,執(zhí)行Node的leave方法,并觸發(fā)Node-leave事件
iter
=
forkedTokens.iterator();
while
(iter.hasNext())
{
ForkedToken forkedToken
=
(ForkedToken) iter.next();
Token childToken
=
forkedToken.token;
String leavingTransitionName
=
forkedToken.leavingTransitionName;
ExecutionContext childExecutionContext
=
new
ExecutionContext(childToken);
if
(leavingTransitionName
!=
null
)
{
leave(childExecutionContext, leavingTransitionName);
}
else
{
leave(childExecutionContext);
}
}
看了這段代碼我們應該明白:Fork的Node-leave事件是會執(zhí)行多遍的,具體要看產生的子Token的個數(shù).至于ForkedToken類,其實是Fork的一個內被類,只起到一個普通Bean的作用.
到這里,F(xiàn)ork類的大體內容我們已經解讀完畢,但是還有一點要注意的地方:
add some way of blocking the current token here and disable that blocking when the join reactivates this token Then an exception can be thrown by in case someone tries to signal a token that is waiting in a fork.Suspend and resume can NOT be used for this since that will also suspend any related timers, tasks and messages...So a separate kind of blocking should be created for this.
文章原創(chuàng),轉載請注明出處!
posted on 2008-11-05 16:41
零全零美
閱讀(2106)
評論(0)
編輯
收藏
所屬分類:
jbpm
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發(fā)表評論。
網站導航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
相關文章:
[原創(chuàng)]巧用System.getProperty()編譯現(xiàn)有工程的java文件
[原創(chuàng)]JBPM源碼解讀之:Join
[原創(chuàng)]JBPM實踐之:并發(fā)子流程的實現(xiàn)
JBPM實踐之:使用Fork中的Script實現(xiàn)多路路由選擇
[原創(chuàng)]JBPM源碼解讀之:Fork
JBPM實踐之:在流程圖上高亮顯示指定的任務節(jié)點
Copyright ©2025 零全零美 Powered By
博客園
模板提供:
滬江博客
主站蜘蛛池模板:
亚洲激情视频图片
|
亚洲精品成人图区
|
免费国产a理论片
|
免费黄色大片网站
|
亚洲AV一二三区成人影片
|
69视频在线观看免费
|
久久精品国产亚洲精品2020
|
日韩免费视频一区二区
|
国产亚洲av片在线观看播放
|
国产免费AV片在线观看
|
亚洲va中文字幕无码久久
|
嫩草影院在线播放www免费观看
|
亚洲av永久无码精品古装片
|
午夜精品一区二区三区免费视频
|
亚洲国产精品特色大片观看完整版
|
久久精品国产这里是免费
|
亚洲一区二区三区高清
|
国产精品久久永久免费
|
国产成人精品日本亚洲18图
|
处破痛哭A√18成年片免费
|
国产偷国产偷亚洲清高APP
|
亚洲国产精品尤物YW在线观看
|
久久国产福利免费
|
亚洲国产精品成人精品无码区
|
99精品一区二区免费视频
|
亚洲人成人77777网站不卡
|
成年女人18级毛片毛片免费观看
|
亚洲1区2区3区精华液
|
亚洲中文字幕无码永久在线
|
无码人妻一区二区三区免费看
|
亚洲日韩精品一区二区三区
|
国产精品偷伦视频观看免费
|
亚洲嫩草影院在线观看
|
国产精品二区三区免费播放心
|
亚洲欧美国产国产综合一区
|
亚洲国产精品综合久久网络
|
久久久久久AV无码免费网站
|
在线观看亚洲AV日韩A∨
|
亚洲中文字幕无码一区
|
麻豆视频免费观看
|
日本免费精品一区二区三区
|