4 Replies Latest reply on Dec 25, 2006 2:24 AM by coolfish007

    XORJoinNode

    yangdaolin

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


        • 1. Re: XORJoinNode
          kukeltje

          cool, thanks. If you want, you can make a wiki page for this.

          • 2. Re: XORJoinNode
            yangdaolin

            OK. I want to know how I make wiki page. thanks!

            • 3. Re: XORJoinNode
              coolfish007

              good idea! but we can refactory this code:

              if (!mergeNode.equals(concurrentToken.getNode()))
              {
              cancelTokenTasks( ctx, concurrentToken );
              concurrentToken.end( false );
              }


              to
              if (!mergeNode.equals(concurrentToken.getNode()))
              {
              concurrentToken.end( false );
              cancelTokenTasks( ctx, concurrentToken );
              }


              because in token.end(),jbpm can set the signalling to false.

              • 4. Re: XORJoinNode
                coolfish007

                And I think before we cancel the task instance ,we need check the task is ended first:

                if(ti.hasEnded()){
                 .......
                 ti.cancel();
                }