1 23 package org.objectweb.joram.client.connector; 24 25 import javax.jms.IllegalStateException ; 26 import javax.jms.JMSException ; 27 import javax.jms.MessageConsumer ; 28 29 import org.objectweb.util.monolog.api.BasicLevel; 30 31 35 public class OutboundConsumer implements javax.jms.MessageConsumer 36 { 37 38 protected OutboundSession session; 39 40 protected MessageConsumer consumer; 41 42 43 boolean valid = true; 44 45 46 52 OutboundConsumer(MessageConsumer consumer, 53 OutboundSession session) { 54 55 if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG)) 56 AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG, 57 "OutboundConsumer(" + consumer + 58 ", " + session + ")"); 59 60 this.consumer = consumer; 61 this.session = session; 62 } 63 64 65 69 public void setMessageListener(javax.jms.MessageListener messageListener) 70 throws JMSException 71 { 72 checkValidity(); 73 throw new IllegalStateException ("Invalid call on a component's producer."); 74 } 75 76 80 public javax.jms.MessageListener getMessageListener() throws JMSException 81 { 82 checkValidity(); 83 throw new IllegalStateException ("Invalid call on a component's producer."); 84 } 85 86 89 public String getMessageSelector() throws JMSException { 90 if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG)) 91 AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG, 92 this + " getMessageSelector()"); 93 94 checkValidity(); 95 return consumer.getMessageSelector(); 96 } 97 98 101 public javax.jms.Message receive(long timeOut) throws JMSException { 102 if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG)) 103 AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG, 104 this + " receive(" + timeOut + ")"); 105 106 checkValidity(); 107 return consumer.receive(timeOut); 108 } 109 110 113 public javax.jms.Message receive() throws JMSException { 114 if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG)) 115 AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG, 116 this + " receive()"); 117 118 checkValidity(); 119 return consumer.receive(); 120 } 121 122 125 public javax.jms.Message receiveNoWait() throws JMSException { 126 if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG)) 127 AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG, 128 this + " receiveNoWait()"); 129 130 checkValidity(); 131 if (!session.isStarted()) 132 return null; 133 return consumer.receiveNoWait(); 134 } 135 136 139 public void close() throws JMSException { 140 if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG)) 141 AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG, 142 this + " close()"); 143 144 valid = false; 145 consumer.close(); 146 } 147 148 149 protected void checkValidity() throws IllegalStateException 150 { 151 session.checkValidity(); 152 153 if (! valid) 154 throw new IllegalStateException ("Invalid call on a closed producer."); 155 } 156 } 157 | Popular Tags |