1 17 package org.apache.servicemix.beanflow; 18 19 import java.util.List ; 20 21 28 public class JoinQuorum extends JoinSupport { 29 30 public JoinQuorum() { 31 super(); 32 33 } 34 35 public JoinQuorum(Activity... activities) { 36 super(activities); 37 } 38 39 public JoinQuorum(List <Activity> activities) { 40 super(activities); 41 } 42 43 protected void onChildStateChange(int childCount, int stoppedCount, int failedCount) { 44 int quorum = calculateQuorum(childCount); 45 int successes = stoppedCount - failedCount; 46 if (successes >= quorum) { 47 stop(); 48 } 49 else { 50 if (failedCount >= quorum) { 51 fail("Too many child activities failed: " + failedCount); 52 } 53 } 54 } 55 56 protected int calculateQuorum(int childCount) { 57 return (childCount / 2) + 1; 58 } 59 } 60 | Popular Tags |