1 package org.jbpm.graph.node; 2 3 import java.util.*; 4 5 import org.jbpm.graph.def.*; 6 import org.jbpm.graph.exe.*; 7 8 15 public class Merge extends Node { 16 17 private static final long serialVersionUID = 1L; 18 19 private boolean isSynchronized = false; 20 21 public Merge() { 22 } 23 24 public Merge(String name) { 25 super(name); 26 } 27 28 public void execute(ExecutionContext executionContext) { 29 Token token = executionContext.getToken(); 30 Node mergeNode = token.getNode(); 31 32 if ( ! isSynchronized ) { 34 mergeNode.leave(executionContext); 35 36 } else { 38 39 Collection concurrentTokens = token.getParent().getChildren().values(); 40 boolean reactivate = true; 41 Iterator iter = concurrentTokens.iterator(); 42 while ( (iter.hasNext()) 43 && (reactivate) ) { 44 Token concurrentToken = (Token) iter.next(); 45 if ( concurrentToken.getNode() != mergeNode ) { 46 reactivate = false; 47 } 48 } 49 50 if ( reactivate ) { 51 iter = concurrentTokens.iterator(); 52 while (iter.hasNext()) { 53 Token concurrentToken = (Token) iter.next(); 54 mergeNode.leave(new ExecutionContext(concurrentToken)); 55 } 56 } 57 } 58 } 59 60 public boolean isSynchronized() { 61 return isSynchronized; 62 } 63 public void setSynchronized(boolean isSynchronized) { 64 this.isSynchronized = isSynchronized; 65 } 66 } 67 | Popular Tags |