*/
BusinessProcess graph = wm.getGraphByID(
eiSvc.getInstanceByID(tk.getInstanceID()).getBusinessProcessID());
Node n = graph.getNode(tk.getCurrentNodeID());
NodeContextImpl nc = new NodeContextImpl(n, ei, timerService,
taskService, notificationService);
nc.setAppData(msg.getAppData());
/*
* now examine the state of this token and process accordingly.
*/
switch(tk.getCurrentState()) {
/*
* in 'pre start' state for this node. Setup, call the doStart()
* method, and then based on the return from doStart(), either
* create and fling another message back into the queue, or stop
* and wait for response from outside
*/
case Token.PRE : {
logger.debug("processMessage : Current state = PRE for " + tk);
/**
* must send new token b/c it can be used as the current token...
*/
Token newToken = tokenService.newToken(tk.getInstanceID(),
tk.getCurrentNodeID(),
Token.MID);
nc.setCurrentExecutionToken(tk);
nc.setNextExecutionToken(newToken);
boolean ret = n.doStart(nc);
if (ret == true) {
EngineMessage newMsg = new EngineMessageImpl();
newMsg.setCurrentTokenID(newToken.getTokenID());
queue.enqueue(newMsg);
}
break;
}
/*
* this state is 'between' doStart() and doEnd(). So prepare
* context and call doEnd()
*/
case Token.MID : {
logger.debug("processMessage : Current state = MID for " + tk);
nc.setCurrentExecutionToken(tk);
/*
* call doEnd() and get the set of conenctions that we need
* to traverse, or null if we are to stop
*/
Connection[] c = n.doEnd(nc);
if (c != null && c.length > 0) {
Token[] newTokens = tokenService.nextToken(c, tk);