1 23 package org.objectweb.joram.client.connector; 24 25 import javax.jms.Destination ; 26 import javax.jms.IllegalStateException ; 27 import javax.jms.JMSException ; 28 import javax.jms.Message ; 29 import javax.jms.MessageProducer ; 30 31 import org.objectweb.util.monolog.api.BasicLevel; 32 33 37 public class OutboundProducer implements javax.jms.MessageProducer 38 { 39 40 protected OutboundSession session; 41 42 protected MessageProducer producer; 43 44 45 boolean valid = true; 46 47 48 54 OutboundProducer(MessageProducer producer, OutboundSession session) { 55 if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG)) 56 AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG, 57 "OutboundProducer(" + producer + 58 ", " + session + ")"); 59 60 this.producer = producer; 61 this.session = session; 62 } 63 64 65 66 public void setDisableMessageID(boolean value) throws JMSException 67 { 68 checkValidity(); 69 producer.setDisableMessageID(value); 70 } 71 72 73 public void setDeliveryMode(int deliveryMode) throws JMSException 74 { 75 checkValidity(); 76 producer.setDeliveryMode(deliveryMode); 77 } 78 79 80 public void setPriority(int priority) throws JMSException 81 { 82 checkValidity(); 83 producer.setPriority(priority); 84 } 85 86 87 public void setTimeToLive(long timeToLive) throws JMSException 88 { 89 checkValidity(); 90 producer.setTimeToLive(timeToLive); 91 } 92 93 94 public void setDisableMessageTimestamp(boolean value) throws JMSException 95 { 96 checkValidity(); 97 producer.setDisableMessageTimestamp(value); 98 } 99 100 101 public Destination getDestination() throws JMSException 102 { 103 checkValidity(); 104 return producer.getDestination(); 105 } 106 107 108 public boolean getDisableMessageID() throws JMSException 109 { 110 checkValidity(); 111 return producer.getDisableMessageID(); 112 } 113 114 115 public int getDeliveryMode() throws JMSException 116 { 117 checkValidity(); 118 return producer.getDeliveryMode(); 119 } 120 121 122 public int getPriority() throws JMSException 123 { 124 checkValidity(); 125 return producer.getPriority(); 126 } 127 128 129 public long getTimeToLive() throws JMSException 130 { 131 checkValidity(); 132 return producer.getTimeToLive(); 133 } 134 135 136 public boolean getDisableMessageTimestamp() throws JMSException 137 { 138 checkValidity(); 139 return producer.getDisableMessageTimestamp(); 140 } 141 142 143 144 public void send(Message message) throws JMSException { 145 if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG)) 146 AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG, this + " send(" + message + ")"); 147 148 checkValidity(); 149 producer.send(message); 150 } 151 152 153 public void send(Message message, 154 int deliveryMode, 155 int priority, 156 long timeToLive) 157 throws JMSException { 158 if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG)) 159 AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG, this + " send(" + message + 160 ", " + deliveryMode + 161 ", " + priority + 162 ", " + timeToLive + ")"); 163 164 checkValidity(); 165 producer.send(message, deliveryMode, priority, timeToLive); 166 } 167 168 169 public void send(Destination dest, Message message) 170 throws JMSException { 171 if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG)) 172 AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG, 173 this + " send(" + dest + ", " + message + ")"); 174 175 checkValidity(); 176 producer.send(dest, message); 177 } 178 179 180 public void send(Destination dest, 181 Message message, 182 int deliveryMode, 183 int priority, 184 long timeToLive) 185 throws JMSException { 186 if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG)) 187 AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG, this + " send(" + dest + 188 ", " + message + 189 ", " + deliveryMode + 190 ", " + priority + 191 ", " + timeToLive + ")"); 192 193 checkValidity(); 194 producer.send(dest, message, deliveryMode, priority, timeToLive); 195 } 196 197 198 public void close() throws JMSException { 199 if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG)) 200 AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG, this + " close()"); 201 202 valid = false; 203 producer.close(); 204 } 205 206 207 protected void checkValidity() throws IllegalStateException 208 { 209 session.checkValidity(); 210 211 if (! valid) 212 throw new IllegalStateException ("Invalid call on a closed producer."); 213 } 214 } 215 | Popular Tags |