1 7 package org.jboss.messaging.channel.plugins.handler; 8 9 import java.util.ArrayList ; 10 11 import org.jboss.messaging.interfaces.*; 12 import org.jboss.messaging.interfaces.Consumer; 13 import org.jboss.messaging.interfaces.MessageReference; 14 15 21 public class SharedChannelHandler extends AbstractChannelHandler 22 { 23 25 27 28 private ArrayList consumers = new ArrayList (); 29 30 32 34 39 public SharedChannelHandler(MessageSet messages) 40 { 41 super(messages); 42 } 43 44 46 48 protected void addConsumer(Consumer consumer, long wait) 49 { 50 consumers.add(consumer); 51 } 52 53 protected Consumer findConsumer(MessageReference reference) 54 { 55 for (int i = 0; i < consumers.size(); ++i) 56 { 57 Consumer consumer = (Consumer) consumers.get(i); 58 if (consumer.accepts(reference, true)) 59 { 60 consumers.remove(i); 61 return consumer; 62 } 63 } 64 return null; 65 } 66 67 protected void removeConsumer(Consumer consumer) 68 { 69 consumers.remove(consumer); 70 } 71 72 74 76 78 } 80 | Popular Tags |