1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.jelly.tags.jms;
17
18 import javax.jms.Message;
19 import javax.jms.JMSException;
20
21 import org.apache.commons.jelly.JellyTagException;
22
23 /*** Creates a JMS TextMessage
24 *
25 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
26 * @version $Revision: 155420 $
27 */
28 public class TextMessageTag extends MessageTag {
29
30 private String text;
31
32 public TextMessageTag() {
33 }
34
35
36
37
38 /***
39 * Sets the body of the message, a String. If this value is not set or
40 * the value is null then the content of the tag will be used instead.
41 */
42 public void setText(String text) {
43 this.text = text;
44 }
45
46
47
48
49 protected Message createMessage() throws JellyTagException {
50 String value = (text != null) ? text : getBodyText();
51 try {
52 return getConnection().createTextMessage(value);
53 } catch (JMSException e) {
54 throw new JellyTagException(e);
55 }
56 }
57 }