4 Replies Latest reply on Dec 25, 2006 2:24 AM by Donald.Liu

    XORJoinNode

    YangDaolin Newbie

      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 );
       }
      }