Version 5

    Here is a custom Xor join handler, which means; it accepts the first token arriving the join and cancels all the rest.

     

    package org.jbpm.delegation.join;
    
    public class XorJoinHandler implements JoinHandler {
    
         public void join(JoinContext joinContext) throws ExecutionException {
    
             // if there is really an arriving token
             if ( joinContext.getConcurrentTokens().size() != 0 ) {
               
                 //get other tokens than the arriving token
                 Collection brotherTokens = joinContext.getConcurrentTokens().values();
                 
                 // get the token arriving in this join 
                 Token arrivingToken = joinContext.getToken();
                 
                 //cancel all living brother tokens...
                 Iterator iter = brotherTokens.iterator();
                 while(iter.hasNext()){
                     Token token = (Token) iter.next();
                        // ExecutionService es = JbpmServiceFactory.getInstance().openExecutionService(token.getActorId());                
                        // the line above resulted in infinite waits to some jdbc-lock method (I'm using postgres). This
                        // works for me and looks "cleaner" to me
                        ExecutionService es = joinContext.getExecutionService(token.getActorId()); 
                     es.cancelToken(token.getId());
                 }
               
                 // reactivate the parent token.
                 joinContext.reactivateToken( arrivingToken.getParent() );
                 
             }
         }
    }
    

          

     

    Use it in processdefinition.xml as such:

     

    <join name="join">
        <delegation class="org.jbpm.delegation.join.XorJoinHandler"></delegation> 
           <transition to="next state" ></transition>
      </join>
    

     

    /

    3.1 can not

    • /