1 7 package org.jboss.messaging.channel.plugins.handler; 8 9 import org.jboss.messaging.channel.interfaces.Channel; 10 import org.jboss.messaging.interfaces.Consumer; 11 import org.jboss.messaging.interfaces.MessageReference; 12 13 19 public abstract class AbstractChannel implements Channel 20 { 21 23 25 26 protected Consumer consumer; 27 28 29 protected ChannelHandler handler; 30 31 33 35 41 public AbstractChannel(Consumer consumer, ChannelHandler handler) 42 { 43 this.consumer = consumer; 44 this.handler = handler; 45 } 46 47 49 51 public void send(MessageReference message) 52 { 53 handler.addMessage(message); 54 } 55 56 public MessageReference receive(long wait) 57 { 58 if (wait == -1) 60 return handler.removeMessage(consumer); 61 62 handler.waitMessage(consumer, wait); 64 return null; 65 } 66 67 public void close() 68 { 69 handler.stopWaitMessage(consumer); 70 } 71 72 74 76 78 } 80 | Popular Tags |