%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.commons.jelly.tags.jms.ObjectMessageTag |
|
|
1 | /* |
|
2 | * Copyright 2002,2004 The Apache Software Foundation. |
|
3 | * |
|
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | * you may not use this file except in compliance with the License. |
|
6 | * You may obtain a copy of the License at |
|
7 | * |
|
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 | * |
|
10 | * Unless required by applicable law or agreed to in writing, software |
|
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 | * See the License for the specific language governing permissions and |
|
14 | * limitations under the License. |
|
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: 1.5 $ |
|
29 | */ |
|
30 | public class ObjectMessageTag extends MessageTag { |
|
31 | ||
32 | private Serializable object; |
|
33 | ||
34 | 0 | public ObjectMessageTag() { |
35 | 0 | } |
36 | ||
37 | // Properties |
|
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 | 0 | this.object = object; |
47 | 0 | } |
48 | ||
49 | // Implementation methods |
|
50 | //------------------------------------------------------------------------- |
|
51 | protected Message createMessage() throws JellyTagException { |
|
52 | 0 | Serializable value = (object != null) ? object : getBodyText(); |
53 | try { |
|
54 | 0 | return getConnection().createObjectMessage(value); |
55 | } |
|
56 | catch (JMSException e) { |
|
57 | 0 | throw new JellyTagException(e); |
58 | } |
|
59 | } |
|
60 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |