1 16 17 package org.apache.taglibs.jms; 18 19 import javax.jms.Destination ; 20 import javax.jms.JMSException ; 21 import javax.jms.Message ; 22 import javax.servlet.jsp.JspException ; 23 24 import org.apache.commons.messenger.Messenger; 25 26 31 public abstract class MessageOperationTag extends AbstractTag implements ConnectionContext { 32 33 34 private Messenger connection; 35 36 37 private Destination destination; 38 39 public MessageOperationTag() { 40 } 41 42 public void release() { 45 super.release(); 46 connection = null; 47 destination = null; 48 } 49 50 51 public Messenger getConnection() throws JspException , JMSException { 54 if ( connection == null ) { 55 return findConnection(); 56 } 57 return connection; 58 } 59 60 public void setConnection(Messenger connection) { 61 this.connection = connection; 62 } 63 64 public Destination getDestination() { 65 return destination; 66 } 67 68 public void setDestination(Destination destination) { 69 this.destination = destination; 70 } 71 72 protected Messenger findConnection() throws JspException , JMSException { 75 ConnectionContext messengerTag = (ConnectionContext) findAncestorWithClass( this, ConnectionContext.class ); 76 if ( messengerTag == null ) { 77 throw new JspException ("This tag must be within a <jms:connection> tag or the 'connection' attribute should be specified"); 78 } 79 return messengerTag.getConnection(); 80 } 81 } 82 | Popular Tags |