3 Replies Latest reply on Nov 22, 2007 6:12 PM by bin yorku

    or join

    xie ping Newbie

      XorJoinHandler
      Your trail:

      --------------------------------------------------------------------------------
      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:







      /* 3.1 can not

      /





      --------------------------------------------------------------------------------
      Go to top Edit this page More info... Attach file...

      XorJoinHandler
      Your trail:

      --------------------------------------------------------------------------------
      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:







      /* 3.1 can not

      /




      how can i use in jbpm 3.1