[jboss-user] [JBoss jBPM] - or join

mygol do-not-reply at jboss.com
Mon Aug 21 10:57:43 EDT 2006


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


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

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



More information about the jboss-user mailing list