???????????????
???? Work Flow
學(xué)習(xí)筆記
1.???
WfRequester
WfRequester
is the interface that has a direct concern with the execution and results
of a workflow process - it represents the request for some work to be done. Its
performer, a WfProcess, is expected to handle its request and communicate significant
status changes; in particular to inform the requester when it has completed performing
the requested work. A single requester can have many processes associated with it.
?
??

?
?
說(shuō)明:
WfRequester
接口是一個(gè)和工作流流程的執(zhí)行及結(jié)果有直接關(guān)系的接口;它代表了對(duì)一些工作執(zhí)行的請(qǐng)求;它的一個(gè)主要功能是把
WfProcess
鏈接到一個(gè)其它應(yīng)用;其中
WfRequester
會(huì)關(guān)聯(lián)到多個(gè)
WfProcee,
當(dāng)
WfProcess
發(fā)生
complete
、
terminate
、
abort
事件時(shí)會(huì)通過(guò)回調(diào)
receiveEvent()
方法來(lái)通知
WfRequest
;在
receiveEvent(event)
方法中,參數(shù)
event
是一個(gè)
WfEventAudit
對(duì)象,其中
WfEventAudit
中有一個(gè)方法
source(),
通過(guò)這個(gè)方法我們可以得知是哪個(gè)
WfExecutionObject
對(duì)象觸發(fā)了事件源;得到了
WfExcutionObject
即
WfProcess
我們也進(jìn)而
得到了和這個(gè)
WfProcess
相關(guān)聯(lián)的其它應(yīng)用;
主要步驟
:
(1)???
自定義一個(gè)自己的類(lèi)或接口,如
GenericRequester,
這個(gè)
GenericRequester
類(lèi)代表用戶自定義的一個(gè)請(qǐng)求者;
(2)???
在啟動(dòng)
WfProcess
是,把這個(gè)請(qǐng)求者和
WfProcess
進(jìn)行綁定注冊(cè)到
WfRequester
中;
?
在
WfReuester
的
registerProcess()
就是做這個(gè)功能,主要代碼如下
protected Map performers = null;
public void registerProcess(WfProcess process, Map context, GenericRequester requester){
??????????????
performers.put(process, requester);
?
}
(3)???
當(dāng)工作流程在執(zhí)行的過(guò)程中發(fā)生
complete
、
terminate
、
abort
事件時(shí)會(huì)回調(diào)
WfRequest
中的
receiveEvent()
方法:
???
?
requester.receiveEvent(audit);
(4)
??
在
receiveEvent()
中首先根據(jù)
WfEventAudit
的
source()
獲取觸發(fā)事件的
WfProcess
對(duì)象;
receiveEvent(WfEventAudit event){
??????? //
獲取事件源
process
對(duì)象
WfProcess? process = (WfProcess) event.source();
//
根據(jù)
prcocess
對(duì)象獲取在注冊(cè)時(shí)綁定的自定義請(qǐng)求者
GenericRequester
GenericRequester ?req = (GenericRequester) performers.get(process);
//
執(zhí)行自定義請(qǐng)求者的方法
req.receiveResult(process.result());
}
其它:在這里
GenericRequester
也可是一個(gè)
WfProcess
或
WfActivity
對(duì)象,這樣可以在
WfProcess
完成操作后又啟動(dòng)另一個(gè)子流程或某個(gè)活動(dòng);
???