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 29 public class SendTag extends MessageOperationTag { 30 31 32 private Message message; 33 34 public SendTag() { 35 } 36 37 public int doStartTag() throws JspException { 40 return EVAL_BODY_INCLUDE; 41 } 42 43 public int doEndTag() throws JspException { 44 try { 45 Message message = getMessage(); 46 if ( message == null ) { 47 throw new JspException ( "No message specified. Either specify a 'message' attribute or use a nested <jms:message> tag" ); 48 } 49 Destination destination = getDestination(); 50 if ( destination == null ) { 51 throw new JspException ( "No destination specified. Either specify a 'destination' attribute or use a nested <jms:destination> tag" ); 52 } 53 getConnection().send( destination, message ); 54 } 55 catch (JMSException e) { 56 throw new JspException ( "Failed to send JMS message: " + e, e ); 57 } 58 return EVAL_PAGE; 59 } 60 61 public void release() { 62 super.release(); 63 message = null; 64 } 65 66 67 public Message getMessage() { 70 return message; 71 } 72 73 public void setMessage(Message message) { 74 this.message = message; 75 } 76 } 77 | Popular Tags |