[jboss-dev-forums] [Design of JBoss jBPM] - XORJoinNode

yangdaolin do-not-reply at jboss.com
Sun Dec 17 09:47:14 EST 2006


I developed a XORJoinNode. When user end a task to enter this node, other tasks of previous nodes will automatically end.


  | public class XORJoinNodeAction
  |     extends Node
  | {
  |     protected void cancelTokenTasks( ExecutionContext executionContext, Token token )
  |     {
  |         TaskMgmtInstance    tms    =    executionContext.getTaskMgmtInstance();
  |         Collection    tasks    =    tms.getUnfinishedTasks( token );
  |         Iterator    it    =    tasks.iterator( );
  |         while( it.hasNext() )
  |         {
  |             TaskInstance    ti    =    (TaskInstance)it.next( );
  |             if( ti.isBlocking( ) )
  |                 ti.setBlocking( false );
  |             if( ti.isSignalling( ) )
  |                 ti.setSignalling( false );
  |             log.debug( "Cancel TaskInstance " + ti.getName() + "(" + ti.getId() + ")" );
  |             ti.cancel( );
  |         }
  |     }
  | 
  |     public void execute(ExecutionContext ctx)
  |     {
  |         Token token = ctx.getToken();
  |         Node mergeNode = token.getNode();
  | 
  |         Collection concurrentTokens = token.getParent().getChildren().values();
  |         Iterator iter = concurrentTokens.iterator();
  |         while ( iter.hasNext() )
  |         {
  |             Token concurrentToken = (Token) iter.next();
  |             concurrentToken.setAbleToReactivateParent( false );
  |             if (!mergeNode.equals(concurrentToken.getNode()))
  |             {
  |                 cancelTokenTasks( ctx, concurrentToken );
  |                 concurrentToken.end( false );
  |             }
  |         }
  | 
  |         leave( ctx );
  |     }
  | }
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3994488#3994488

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3994488



More information about the jboss-dev-forums mailing list