%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.commons.jelly.tags.jms.ConnectionTag |
|
|
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 javax.jms.JMSException; |
|
19 | ||
20 | import org.apache.commons.jelly.JellyTagException; |
|
21 | import org.apache.commons.jelly.TagSupport; |
|
22 | import org.apache.commons.jelly.XMLOutput; |
|
23 | import org.apache.commons.messenger.Messenger; |
|
24 | import org.apache.commons.messenger.MessengerManager; |
|
25 | ||
26 | /** Defines a JMS connection for use by other JMS tags. |
|
27 | * |
|
28 | * @author <a href="mailto:jstrachan@apache.org">James Strachan</a> |
|
29 | * @version $Revision: 1.5 $ |
|
30 | */ |
|
31 | 0 | public class ConnectionTag extends TagSupport implements ConnectionContext { |
32 | ||
33 | /** The variable name to create */ |
|
34 | private String var; |
|
35 | ||
36 | /** Stores the name of the map entry */ |
|
37 | private String name; |
|
38 | ||
39 | /** The Messenger */ |
|
40 | private Messenger connection; |
|
41 | ||
42 | // ConnectionContext interface |
|
43 | //------------------------------------------------------------------------- |
|
44 | public Messenger getConnection() { |
|
45 | 0 | return connection; |
46 | } |
|
47 | ||
48 | // Tag interface |
|
49 | //------------------------------------------------------------------------- |
|
50 | public void doTag(XMLOutput output) throws JellyTagException { |
|
51 | ||
52 | try { |
|
53 | 0 | connection = MessengerManager.get( name ); |
54 | 0 | } |
55 | catch (JMSException e) { |
|
56 | 0 | throw new JellyTagException(e); |
57 | } |
|
58 | ||
59 | 0 | if (connection == null) { |
60 | 0 | throw new JellyTagException( "Could not find a JMS connection called: " + name ); |
61 | } |
|
62 | ||
63 | 0 | if ( var != null ) { |
64 | 0 | context.setVariable( var, connection ); |
65 | } |
|
66 | ||
67 | 0 | invokeBody(output); |
68 | 0 | } |
69 | ||
70 | // Properties |
|
71 | //------------------------------------------------------------------------- |
|
72 | ||
73 | /** Sets the name of the Messenger (JMS connection pool) to use |
|
74 | */ |
|
75 | public void setName(String name) { |
|
76 | 0 | this.name = name; |
77 | 0 | } |
78 | ||
79 | /** Sets the variable name to use for the exported Messenger (JMS connection pool) |
|
80 | */ |
|
81 | public void setVar(String var) { |
|
82 | 0 | this.var = class="keyword">var; |
83 | 0 | } |
84 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |