[JBoss jBPM] - or join
by mygol
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
19 years, 8 months
[JBossCache] - Re: how to support treecache transaction in CMT
by bstansberry@jboss.com
Was just about to say that looks fine too, when I saw the problem :)
The fact that you put your Person object in the cache doesn't make the Person object transactional. You are changing the person object by changing the address -- that change won't roll back.
To get what you want you'd need something more like:
| if("add".equals(command)){
| Person old = ((Person)cache.get("/test/p1","p1"));
| Person clone = (Person) old.clone();
| Address oldAdd = clone.getAddress();
| Address addClone = (Address) oldAdd.clone();
| addClone.setCity(value);
| clone.setAddress(addClone);
| cache.put("/test/a1","a1" ,clone);
|
| if("pp".equals(key)){
| System.out.println("Gettttttttttttttbefore:a1=" + cache.get("/test/a1","a1"));
| throw new Exception("throw exception for rollback");
| }
|
| }
Usual warning that above code is for illustration, may not compile, etc.
To have changes to your objects be transactional, you'd need to use PojoCache and instrument your classes.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3966456#3966456
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3966456
19 years, 8 months