1 /* 2 * Copyright (C) The Apache Software Foundation. All rights reserved. 3 * 4 * This software is published under the terms of the Apache Software License 5 * version 1.1, a copy of which has been included with this distribution in 6 * the LICENSE file. 7 * 8 * $Id: MessengerMDO.java 155459 2005-02-26 13:24:44Z dirkv $ 9 */ 10 11 package org.apache.commons.messagelet; 12 13 import javax.jms.JMSException; 14 15 import org.apache.commons.messenger.Messenger; 16 import org.apache.commons.messenger.MessengerListener; 17 import org.apache.commons.messenger.MessengerManager; 18 19 /** <p><code>MessengerMDO</code> is an abstract base 20 * class for Messenger based MDO implementations. 21 * It provides access to the Messenger that was used to receive messages 22 * so that responses can be sent to the originating Messenger object 23 * and so reuse the same JMS Session and Connection for responses.</p> 24 * 25 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a> 26 * @version $Revision: 155459 $ 27 */ 28 29 public abstract class MessengerMDO 30 extends MessageDrivenObjectSupport 31 implements MessengerListener { 32 33 /** the Messenger with which this MDO is associated */ 34 private Messenger messenger; 35 36 /** the MessengerManager which manages the Messenger */ 37 private MessengerManager messengerManager; 38 39 public MessengerMDO() { 40 41 } 42 43 /** 44 * Provides access to the current Messenger which was used to generate the current 45 * Message. This allows replies to be sent directly to the originating Messenger 46 * (and so the same JMS Session and Connection) which received the message 47 */ 48 public Messenger getMessenger() { 49 return messenger; 50 } 51 52 public void setMessenger(Messenger messenger) { 53 this.messenger = messenger; 54 } 55 56 /** 57 * Provides access to the current MessengerManager which 58 * manages the Messenger 59 */ 60 public MessengerManager getMessengerManager() throws JMSException { 61 if ( messengerManager == null ) { 62 messengerManager = MessengerManager.getInstance(); 63 } 64 return messengerManager; 65 } 66 67 public void setMessengerManager(MessengerManager messengerManager) { 68 this.messengerManager = messengerManager; 69 } 70 71 }