001 /* 002 * Copyright (C) The Apache Software Foundation. All rights reserved. 003 * 004 * This software is published under the terms of the Apache Software License 005 * version 1.1, a copy of which has been included with this distribution in 006 * the LICENSE file. 007 * 008 * $Id: MessengerMDO.java 155459 2005-02-26 13:24:44Z dirkv $ 009 */ 010 011 package org.apache.commons.messagelet; 012 013 import javax.jms.JMSException; 014 015 import org.apache.commons.messenger.Messenger; 016 import org.apache.commons.messenger.MessengerListener; 017 import org.apache.commons.messenger.MessengerManager; 018 019 /** <p><code>MessengerMDO</code> is an abstract base 020 * class for Messenger based MDO implementations. 021 * It provides access to the Messenger that was used to receive messages 022 * so that responses can be sent to the originating Messenger object 023 * and so reuse the same JMS Session and Connection for responses.</p> 024 * 025 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a> 026 * @version $Revision: 155459 $ 027 */ 028 029 public abstract class MessengerMDO 030 extends MessageDrivenObjectSupport 031 implements MessengerListener { 032 033 /** the Messenger with which this MDO is associated */ 034 private Messenger messenger; 035 036 /** the MessengerManager which manages the Messenger */ 037 private MessengerManager messengerManager; 038 039 public MessengerMDO() { 040 041 } 042 043 /** 044 * Provides access to the current Messenger which was used to generate the current 045 * Message. This allows replies to be sent directly to the originating Messenger 046 * (and so the same JMS Session and Connection) which received the message 047 */ 048 public Messenger getMessenger() { 049 return messenger; 050 } 051 052 public void setMessenger(Messenger messenger) { 053 this.messenger = messenger; 054 } 055 056 /** 057 * Provides access to the current MessengerManager which 058 * manages the Messenger 059 */ 060 public MessengerManager getMessengerManager() throws JMSException { 061 if ( messengerManager == null ) { 062 messengerManager = MessengerManager.getInstance(); 063 } 064 return messengerManager; 065 } 066 067 public void setMessengerManager(MessengerManager messengerManager) { 068 this.messengerManager = messengerManager; 069 } 070 071 }