1 16 17 package org.apache.taglibs.jms; 18 19 import javax.jms.JMSException ; 20 import javax.jms.Message ; 21 import javax.servlet.jsp.JspException ; 22 import javax.servlet.jsp.tagext.BodyContent ; 23 import javax.servlet.jsp.tagext.BodyTag ; 24 25 30 public class TextMessageTag extends MessageTag implements BodyTag { 31 32 private BodyContent bodyContent; 33 private String body; 34 35 public TextMessageTag() { 36 } 37 38 public void doInitBody() { 41 } 42 43 public int doStartTag() { 44 if ( body != null ) { 45 return EVAL_BODY_INCLUDE; 46 } 47 return EVAL_BODY_BUFFERED; 48 } 49 50 public int doAfterBody() { 51 return SKIP_BODY; 52 } 53 54 public void setBodyContent(BodyContent bodyContent) { 55 this.bodyContent = bodyContent; 56 } 57 58 public void release() { 59 super.release(); 60 body = null; 61 bodyContent = null; 62 } 63 64 public void setBody(String body) throws JMSException { 67 this.body = body; 68 } 69 70 protected Message createMessage() throws JspException , JMSException { 73 String text = (body != null) ? body : bodyContent.getString(); 74 return getConnection().createTextMessage(text); 75 } 76 } 77 | Popular Tags |