%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.commons.jelly.tags.jms.MapMessageTag |
|
|
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.util.Iterator; |
|
19 | import java.util.Map; |
|
20 | ||
21 | import javax.jms.Message; |
|
22 | import javax.jms.MapMessage; |
|
23 | import javax.jms.JMSException; |
|
24 | ||
25 | import org.apache.commons.jelly.JellyTagException; |
|
26 | ||
27 | /** Creates a JMS MapMessage |
|
28 | * |
|
29 | * @author <a href="mailto:jstrachan@apache.org">James Strachan</a> |
|
30 | * @version $Revision: 1.5 $ |
|
31 | */ |
|
32 | public class MapMessageTag extends MessageTag { |
|
33 | ||
34 | 0 | public MapMessageTag() { |
35 | 0 | } |
36 | ||
37 | public void addEntry(String name, Object value) throws JellyTagException { |
|
38 | 0 | MapMessage message = (MapMessage) getMessage(); |
39 | try { |
|
40 | 0 | message.setObject(name, value); |
41 | 0 | } |
42 | catch (JMSException e) { |
|
43 | 0 | throw new JellyTagException(e); |
44 | } |
|
45 | 0 | } |
46 | ||
47 | // Properties |
|
48 | //------------------------------------------------------------------------- |
|
49 | ||
50 | /** |
|
51 | * Sets the Map of entries to be used for this Map Message |
|
52 | */ |
|
53 | public void setMap(Map map) throws JellyTagException { |
|
54 | 0 | MapMessage message = (MapMessage) getMessage(); |
55 | 0 | for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) { |
56 | 0 | Map.Entry entry = (Map.Entry) iter.next(); |
57 | 0 | String name = entry.getKey().toString(); |
58 | 0 | Object value = entry.getValue(); |
59 | ||
60 | try { |
|
61 | 0 | message.setObject(name, value); |
62 | 0 | } |
63 | catch (JMSException e) { |
|
64 | 0 | throw new JellyTagException(e); |
65 | } |
|
66 | } |
|
67 | 0 | } |
68 | ||
69 | // Implementation methods |
|
70 | //------------------------------------------------------------------------- |
|
71 | protected Message createMessage() throws JellyTagException { |
|
72 | try { |
|
73 | 0 | return getConnection().createMapMessage(); |
74 | } catch (JMSException e) { |
|
75 | 0 | throw new JellyTagException(e); |
76 | } |
|
77 | } |
|
78 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |