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 java.io.Serializable;
19
20 import javax.jms.JMSException;
21 import javax.jms.Message;
22
23 import org.apache.commons.jelly.JellyTagException;
24
25 /*** Creates a JMS ObjectMessage
26 *
27 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
28 * @version $Revision: 155420 $
29 */
30 public class ObjectMessageTag extends MessageTag {
31
32 private Serializable object;
33
34 public ObjectMessageTag() {
35 }
36
37
38
39
40 /***
41 * Sets the body of the message, a serializable java object.
42 * If this value is not set or the value is null then the content
43 * of the tag will be used instead.
44 */
45 public void setObject(Serializable object) {
46 this.object = object;
47 }
48
49
50
51 protected Message createMessage() throws JellyTagException {
52 Serializable value = (object != null) ? object : getBodyText();
53 try {
54 return getConnection().createObjectMessage(value);
55 }
56 catch (JMSException e) {
57 throw new JellyTagException(e);
58 }
59 }
60 }