1 7 package org.jboss.jms.client; 8 9 import javax.jms.Destination ; 10 import javax.jms.JMSException ; 11 import javax.jms.Message ; 12 import javax.jms.MessageConsumer ; 13 import javax.jms.MessageListener ; 14 import javax.jms.Queue ; 15 import javax.jms.QueueReceiver ; 16 import javax.jms.Topic ; 17 import javax.jms.TopicSubscriber ; 18 19 25 public class JBossConsumer 26 implements MessageConsumer , QueueReceiver , TopicSubscriber 27 { 28 30 32 33 private ConsumerDelegate delegate; 34 35 36 private Destination defaultDestination; 37 38 39 private MessageListener listener; 40 41 42 private String selector; 43 44 45 private boolean noLocal; 46 47 49 51 60 public JBossConsumer(ConsumerDelegate delegate, Destination destination, String selector, boolean noLocal) 61 throws JMSException 62 { 63 this.delegate = delegate; 64 this.defaultDestination = destination; 65 this.selector = selector; 66 this.noLocal = noLocal; 67 } 68 69 71 public Destination getDestination() throws JMSException 72 { 73 return defaultDestination; 74 } 75 76 78 public void close() throws JMSException 79 { 80 delegate.closing(); 81 delegate.close(); 82 } 83 84 public MessageListener getMessageListener() throws JMSException 85 { 86 return listener; 87 } 88 89 public String getMessageSelector() throws JMSException 90 { 91 return selector; 92 } 93 94 public Message receive() throws JMSException 95 { 96 return receive(0); 97 } 98 99 public Message receive(long timeout) throws JMSException 100 { 101 return delegate.receive(timeout); 102 } 103 104 public Message receiveNoWait() throws JMSException 105 { 106 return receive(-1); 107 } 108 109 public void setMessageListener(MessageListener listener) throws JMSException 110 { 111 delegate.setMessageListener(listener); 112 this.listener = listener; 113 } 114 115 117 public Queue getQueue() throws JMSException 118 { 119 return (Queue ) getDestination(); 120 } 121 122 124 public boolean getNoLocal() throws JMSException 125 { 126 return noLocal; 127 } 128 129 public Topic getTopic() throws JMSException 130 { 131 return (Topic ) getDestination(); 132 } 133 134 136 138 140 } 142 | Popular Tags |