| 1 46 47 package org.mr.ra; 48 49 import java.io.Serializable ; 50 51 import javax.jms.BytesMessage ; 52 import javax.jms.Destination ; 53 import javax.jms.IllegalStateException ; 54 import javax.jms.JMSException ; 55 import javax.jms.MapMessage ; 56 import javax.jms.Message ; 57 import javax.jms.MessageConsumer ; 58 import javax.jms.MessageListener ; 59 import javax.jms.MessageProducer ; 60 import javax.jms.ObjectMessage ; 61 import javax.jms.Queue ; 62 import javax.jms.QueueBrowser ; 63 import javax.jms.QueueReceiver ; 64 import javax.jms.QueueSender ; 65 import javax.jms.QueueSession ; 66 import javax.jms.Session ; 67 import javax.jms.StreamMessage ; 68 import javax.jms.TemporaryQueue ; 69 import javax.jms.TemporaryTopic ; 70 import javax.jms.TextMessage ; 71 import javax.jms.Topic ; 72 import javax.jms.TopicPublisher ; 73 import javax.jms.TopicSession ; 74 import javax.jms.TopicSubscriber ; 75 76 import org.apache.commons.logging.Log; 77 import org.apache.commons.logging.LogFactory; 78 import org.mr.api.jms.MantaSession; 79 80 86 public class JMSSessionProxy implements Session , QueueSession , TopicSession { 87 88 static final private Log log = LogFactory.getLog(JMSSessionProxy.class); 89 90 private final MantaSession session; 91 boolean closed = false; 92 93 public JMSSessionProxy(MantaSession session) { 94 log.info("JMSSessionProxy()"); 95 this.session = session; 96 } 97 98 public void setUseSharedTxContext(boolean enable) throws JMSException { 99 log.info("setUseSharedTxContext()"); 100 ((RATransactionContext)session.getTransactionContext()).setUseSharedTxContext(enable); 101 } 102 103 106 public void close() throws JMSException { 107 log.info("close()"); 108 cleanup(); 109 } 110 111 117 public void cleanup() throws JMSException { 118 log.info("cleanup()"); 119 closed = true; 120 session.close(); 121 } 122 123 126 private Session getSession() throws JMSException { 127 log.info("getSession()"); 128 if (closed) { 129 throw new IllegalStateException ("The Session is closed"); 130 } 131 return session; 132 } 133 134 137 public void commit() throws JMSException { 138 log.info("commit()"); 139 getSession().commit(); 140 } 141 142 147 public QueueBrowser createBrowser(Queue queue) throws JMSException { 148 log.info("createBrowser(Queue)"); 149 return getSession().createBrowser(queue); 150 } 151 152 158 public QueueBrowser createBrowser(Queue queue, String messageSelector) throws JMSException { 159 log.info("createBrowser(Queue, String)"); 160 return getSession().createBrowser(queue, messageSelector); 161 } 162 163 167 public BytesMessage createBytesMessage() throws JMSException { 168 log.info("createBytesMessage()"); 169 return getSession().createBytesMessage(); 170 } 171 172 177 public MessageConsumer createConsumer(Destination destination) throws JMSException { 178 log.info("createConsumer(Destination)"); 179 return getSession().createConsumer(destination); 180 } 181 182 188 public MessageConsumer createConsumer(Destination destination, String messageSelector) throws JMSException { 189 log.info("createConsumer(Destination, String)"); 190 return getSession().createConsumer(destination, messageSelector); 191 } 192 193 200 public MessageConsumer createConsumer(Destination destination, String messageSelector, boolean NoLocal) 201 throws JMSException { 202 log.info("createConsumer(Destination, String, boolean)"); 203 return getSession().createConsumer(destination, messageSelector, NoLocal); 204 } 205 206 212 public TopicSubscriber createDurableSubscriber(Topic topic, String name) throws JMSException { 213 log.info("createDurableSubscriber(Topic, String)"); 214 return getSession().createDurableSubscriber(topic, name); 215 } 216 217 225 public TopicSubscriber createDurableSubscriber(Topic topic, 226 String name, 227 String messageSelector, 228 boolean noLocal) 229 throws JMSException { 230 log.info("createDurableSubscriber(Topic, String, String, boolean)"); 231 return getSession().createDurableSubscriber(topic, name, messageSelector, noLocal); 232 } 233 234 238 public MapMessage createMapMessage() throws JMSException { 239 log.info("createMapMessage()"); 240 return getSession().createMapMessage(); 241 } 242 243 247 public Message createMessage() throws JMSException { 248 log.info("createMessage()"); 249 return getSession().createMessage(); 250 } 251 252 256 public ObjectMessage createObjectMessage() throws JMSException { 257 log.info("createObjectMessage()"); 258 return getSession().createObjectMessage(); 259 } 260 261 266 public ObjectMessage createObjectMessage(Serializable object) throws JMSException { 267 log.info("createObjectMessage(Serializable)"); 268 return getSession().createObjectMessage(object); 269 } 270 271 276 public MessageProducer createProducer(Destination destination) throws JMSException { 277 log.info("createProducer()"); 278 return getSession().createProducer(destination); 279 } 280 281 286 public Queue createQueue(String queueName) throws JMSException { 287 log.info("createQueue()"); 288 return getSession().createQueue(queueName); 289 } 290 291 295 public StreamMessage createStreamMessage() throws JMSException { 296 log.info("createStreamMessage()"); 297 return getSession().createStreamMessage(); 298 } 299 300 304 public TemporaryQueue createTemporaryQueue() throws JMSException { 305 log.info("createTemporaryQueue()"); 306 return getSession().createTemporaryQueue(); 307 } 308 309 313 public TemporaryTopic createTemporaryTopic() throws JMSException { 314 log.info("createTemporaryTopic()"); 315 return getSession().createTemporaryTopic(); 316 } 317 318 322 public TextMessage createTextMessage() throws JMSException { 323 log.info("createTextMessage()"); 324 return getSession().createTextMessage(); 325 } 326 327 332 public TextMessage createTextMessage(String text) throws JMSException { 333 log.info("createTextMessage(String)"); 334 return getSession().createTextMessage(text); 335 } 336 337 342 public Topic createTopic(String topicName) throws JMSException { 343 log.info("createTopic()"); 344 return getSession().createTopic(topicName); 345 } 346 347 351 public int getAcknowledgeMode() throws JMSException { 352 log.info("getAcknowledgeMode()"); 353 return getSession().getAcknowledgeMode(); 354 } 355 356 360 public MessageListener getMessageListener() throws JMSException { 361 log.info("getMessageListener()"); 362 return getSession().getMessageListener(); 363 } 364 365 369 public boolean getTransacted() throws JMSException { 370 log.info("getTransacted()"); 371 return getSession().getTransacted(); 372 } 373 374 377 public void recover() throws JMSException { 378 log.info("recover()"); 379 getSession().recover(); 380 } 381 382 385 public void rollback() throws JMSException { 386 log.info("rollback()"); 387 getSession().rollback(); 388 } 389 390 394 public void setMessageListener(MessageListener listener) throws JMSException { 395 log.info("setMessageListener() - take a look here!"); 396 getSession().setMessageListener(listener); 397 } 398 399 403 public void unsubscribe(String name) throws JMSException { 404 log.info("unsubscribe()"); 405 getSession().unsubscribe(name); 406 } 407 408 413 public QueueReceiver createReceiver(Queue queue) throws JMSException { 414 log.info("createReceiver(Queue)"); 415 return ((QueueSession ) getSession()).createReceiver(queue); 416 } 417 418 424 public QueueReceiver createReceiver(Queue queue, String messageSelector) throws JMSException { 425 log.info("createReceiver(Queue, String)"); 426 return ((QueueSession ) getSession()).createReceiver(queue, messageSelector); 427 } 428 429 434 public QueueSender createSender(Queue queue) throws JMSException { 435 log.info("createSender()"); 436 return ((QueueSession ) getSession()).createSender(queue); 437 } 438 439 444 public TopicPublisher createPublisher(Topic topic) throws JMSException { 445 log.info("createPublisher()"); 446 return ((TopicSession ) getSession()).createPublisher(topic); 447 } 448 449 454 public TopicSubscriber createSubscriber(Topic topic) throws JMSException { 455 log.info("createSubscriber(Topic)"); 456 return ((TopicSession ) getSession()).createSubscriber(topic); 457 } 458 459 466 public TopicSubscriber createSubscriber(Topic topic, 467 String messageSelector, 468 boolean noLocal) 469 throws JMSException { 470 log.info("JMSSessionProxy(Topic, String, boolean)"); 471 return ((TopicSession ) getSession()).createSubscriber(topic, messageSelector, noLocal); 472 } 473 474 477 public void run() { 478 log.info("run() - no support"); 479 throw new RuntimeException ("Operation not supported."); 480 } 481 482 } 483 | Popular Tags |