オープンソースワークフローFireflowソースコード分析のActivity Instance fired
2650 ワード
ActivityInstance.java
AbstractNodeInstance.java
Activity InstanceのデフォルトのイベントリスナーはActivity InstanceExtensionです
/* Activity
* @see org.fireflow.kernel.INodeInstance#fire(org.fireflow.kernel.IToken)
*/
public void fire(IToken tk) throws KernelException {
// .
log.debug("The weight of the Entering TransitionInstance is " + tk.getValue());
IToken token = tk;
// ID
token.setNodeId(this.getActivity().getId());
// Activity Entered
NodeInstanceEvent event1 = new NodeInstanceEvent(this);
event1.setToken(tk);
event1.setEventType(NodeInstanceEvent.NODEINSTANCE_TOKEN_ENTERED);
fireNodeEvent(event1);
// token
// : token (alive or dead), TranstionInstance , << Fireflow >>
if (token.isAlive()) {
// Activity Fired
NodeInstanceEvent event = new NodeInstanceEvent(this);
event.setToken(token);
event.setEventType(NodeInstanceEvent.NODEINSTANCE_FIRED);
//
fireNodeEvent(event);
} else {
// token dead , 。
// << Fireflow ActivityInstance completed .doc>>
this.complete(token, null);
}
}
AbstractNodeInstance.java
/**
* ActivityInstance ,
* @param event
* @throws KernelException
*/
public void fireNodeEvent(NodeInstanceEvent event) throws KernelException{
// ,
for (int i=0;i<this.eventListeners.size();i++){
INodeInstanceEventListener listener = this.eventListeners.get(i);
listener.onNodeInstanceEventFired(event);
}
}
Activity InstanceのデフォルトのイベントリスナーはActivity InstanceExtensionです
/* ActivityInstance
* @see org.fireflow.kernel.event.INodeInstanceEventListener#onNodeInstanceEventFired(org.fireflow.kernel.event.NodeInstanceEvent)
*/
public void onNodeInstanceEventFired(NodeInstanceEvent e)
throws KernelException {
// fired
if (e.getEventType() == NodeInstanceEvent.NODEINSTANCE_FIRED) {
// spring
IPersistenceService persistenceService = rtCtx.getPersistenceService();
// token, taskinstance
persistenceService.saveOrUpdateToken(e.getToken());
// task , activity Task.
// << Fireflow ActivityInstance Created Task>>
rtCtx.getTaskInstanceManager().createTaskInstances(e.getToken(), (IActivityInstance) e.getSource());
} else if (e.getEventType() == NodeInstanceEvent.NODEINSTANCE_COMPLETED) {
// completed,
}
}