1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.jelly.tags.jms;
18
19 import org.apache.commons.jelly.JellyTagException;
20 import org.apache.commons.jelly.MissingAttributeException;
21 import org.apache.commons.jelly.TagSupport;
22 import org.apache.commons.jelly.XMLOutput;
23
24 /*** Defines a property on an outer JMS Message tag
25 *
26 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
27 * @version $Revision: 155420 $
28 */
29 public class PropertyTag extends TagSupport {
30
31 /*** Stores the name of the property */
32 private String name;
33
34 /*** Stores the value of the property */
35 private Object value;
36
37
38
39
40 public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException {
41 if ( name == null ) {
42 throw new MissingAttributeException("name");
43 }
44 MessageTag tag = (MessageTag) findAncestorWithClass( MessageTag.class );
45 if ( tag == null ) {
46 throw new JellyTagException("<jms:property> tag must be within a <jms:message> tag");
47 }
48
49 if ( value != null ) {
50 tag.addProperty(name, value);
51 }
52 else {
53 tag.addProperty(name, getBodyText());
54 }
55 }
56
57
58
59
60 /*** Sets the name of the JMS property
61 */
62 public void setName(String name) {
63 this.name = name;
64 }
65
66 /*** Sets the value of the JMS property.
67 * If no value is set then the body of the tag is used
68 */
69 public void setValue(Object value) {
70 this.value = value;
71 }
72 }