1 24 25 package org.objectweb.dream.router; 26 27 import java.util.Collection ; 28 import java.util.Iterator ; 29 import java.util.Map ; 30 31 import org.objectweb.dream.Push; 32 import org.objectweb.dream.message.Message; 33 34 39 public class RouterRoundRobinImpl extends AbstractRouterImpl 40 { 41 42 private int nextOutPushIndex = -1; 43 Push[] itfs; 44 45 49 protected Push getOutput(Message message, Map context) 50 { 51 if (!initialized) 52 { 53 Collection values = outPushMap.values(); 54 Iterator iter = values.iterator(); 55 itfs = new Push[values.size()]; 56 int i = 0; 57 while (iter.hasNext()) 58 { 59 itfs[i] = (Push) iter.next(); 60 i++; 61 } 62 initialized = true; 63 } 64 if (itfs.length > 0) 65 { 66 nextOutPushIndex = (nextOutPushIndex + 1) % itfs.length; 67 return itfs[nextOutPushIndex]; 68 } 69 return null; 70 } 71 72 } | Popular Tags |