|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
JMSSession.java | - | 53.3% | 56.2% | 54.8% |
|
1 | /** | |
2 | * JTRunner is free software; you can redistribute it and/or modify it under the | |
3 | * terms of the GNU General Public License as published by the Free Software | |
4 | * Foundation; either version 2, or (at your option) any later version. | |
5 | */ | |
6 | ||
7 | package jtr.config.jms; | |
8 | ||
9 | import java.io.Serializable; | |
10 | ||
11 | /** | |
12 | * This is the object oriented representation of a <code>session</code> | |
13 | * element of the <code>jtr.xml</code> configuration file.<br> | |
14 | * It logically maps itself to a <code>javax.jms.Session</code>. | |
15 | * | |
16 | * @author Francesco Russo (frusso@dev.java.net) | |
17 | * @version 4.0 | |
18 | * @since 1.1 | |
19 | */ | |
20 | public class JMSSession implements Serializable { | |
21 | /** | |
22 | * The default constructor. | |
23 | */ | |
24 | 1 | public JMSSession() { |
25 | } | |
26 | ||
27 | /** | |
28 | * Set the type of the session. Legal values are <code>queue | topic</code>. | |
29 | * | |
30 | * @param type | |
31 | * The session type | |
32 | */ | |
33 | 4 | public void setType(String type) { |
34 | 4 | this.type = type; |
35 | } | |
36 | ||
37 | /** | |
38 | * Get the session type. Legal values are <code>queue | topic</code>. | |
39 | * | |
40 | * @return String The session type | |
41 | */ | |
42 | 0 | public String getType() { |
43 | 0 | return type; |
44 | } | |
45 | ||
46 | /** | |
47 | * Set the name of the runner property that will hold the actual JMS session | |
48 | * once created | |
49 | * | |
50 | * @param property | |
51 | * The property name | |
52 | */ | |
53 | 4 | public void setProperty(String property) { |
54 | 4 | this.property = property; |
55 | } | |
56 | ||
57 | /** | |
58 | * Get the name of the runner property that will hold the actual JMS session | |
59 | * once created | |
60 | * | |
61 | * @return String The property name | |
62 | */ | |
63 | 14 | public String getProperty() { |
64 | 14 | return property; |
65 | } | |
66 | ||
67 | /** | |
68 | * Set the JMS session's transacted attribute | |
69 | * | |
70 | * @param t | |
71 | * Is the session transacted? | |
72 | */ | |
73 | 4 | public void setTransacted(boolean t) { |
74 | 4 | transacted = t; |
75 | } | |
76 | ||
77 | /** | |
78 | * Get the JMS session's transacted attribute | |
79 | * | |
80 | * @return boolean Is the session transacted? | |
81 | */ | |
82 | 14 | public boolean getTransacted() { |
83 | 14 | return transacted; |
84 | } | |
85 | ||
86 | /** | |
87 | * Set the JMS ACK mode. | |
88 | * | |
89 | * @param mode | |
90 | * The ACK mode | |
91 | */ | |
92 | 4 | public void setAckMode(int mode) { |
93 | 4 | ackMode = mode; |
94 | } | |
95 | ||
96 | /** | |
97 | * Get the JMS ACK mode. | |
98 | * | |
99 | * @return int The ACK mode | |
100 | */ | |
101 | 14 | public int getAckMode() { |
102 | 14 | return ackMode; |
103 | } | |
104 | ||
105 | /** | |
106 | * States whether the given <code>JMSSession</code> is a queue session or | |
107 | * not | |
108 | * | |
109 | * @param jmsSession | |
110 | * JMSSession | |
111 | * @return boolean | |
112 | */ | |
113 | 0 | public static boolean isQueueSession(JMSSession jmsSession) { |
114 | 0 | return QUEUE_SESSION.equals(jmsSession.getType().trim().toLowerCase()); |
115 | } | |
116 | ||
117 | /** | |
118 | * States whether the given <code>JMSSession</code> is a topic session or | |
119 | * not | |
120 | * | |
121 | * @param jmsSession | |
122 | * JMSSession | |
123 | * @return boolean | |
124 | */ | |
125 | 0 | public static boolean isTopicSession(JMSSession jmsSession) { |
126 | 0 | return TOPIC_SESSION.equals(jmsSession.getType().trim().toLowerCase()); |
127 | } | |
128 | ||
129 | /** | |
130 | * States whether the given <code>JMSSession</code> is a generic session | |
131 | * or not | |
132 | * | |
133 | * @param jmsSession | |
134 | * JMSSession | |
135 | * @return boolean | |
136 | */ | |
137 | 0 | public static boolean isGenericSession(JMSSession jmsSession) { |
138 | 0 | return GENERIC_SESSION.equals(jmsSession.getType().trim().toLowerCase()); |
139 | } | |
140 | ||
141 | /** | |
142 | * States whether the given <code>JMSSession</code> is an XA session or | |
143 | * not | |
144 | * | |
145 | * @param jmsSession | |
146 | * JMSSession | |
147 | * @return boolean | |
148 | */ | |
149 | 0 | public static boolean isXaSession(JMSSession jmsSession) { |
150 | 0 | return XA_SESSION.equals(jmsSession.getType().trim().toLowerCase()); |
151 | } | |
152 | ||
153 | /** | |
154 | * States whether the given <code>JMSSession</code> is an XAQueue session | |
155 | * or not | |
156 | * | |
157 | * @param jmsSession | |
158 | * JMSSession | |
159 | * @return boolean | |
160 | */ | |
161 | 0 | public static boolean isXaQueueSession(JMSSession jmsSession) { |
162 | 0 | return XA_QUEUE_SESSION.equals(jmsSession.getType().trim().toLowerCase()); |
163 | } | |
164 | ||
165 | /** | |
166 | * States whether the given <code>JMSSession</code> is an XATopic session | |
167 | * or not | |
168 | * | |
169 | * @param jmsSession | |
170 | * JMSSession | |
171 | * @return boolean | |
172 | */ | |
173 | 0 | public static boolean isXaTopicSession(JMSSession jmsSession) { |
174 | 0 | return XA_TOPIC_SESSION.equals(jmsSession.getType().trim().toLowerCase()); |
175 | } | |
176 | ||
177 | /** | |
178 | * @see java.lang.Object#toString() | |
179 | */ | |
180 | 14 | public String toString() { |
181 | 14 | return "Session: type " + type + " - property " + property + " - transacted " + transacted + " - ackMode " + ackMode + "\n"; |
182 | } | |
183 | ||
184 | private String type; | |
185 | ||
186 | private String property; | |
187 | ||
188 | private boolean transacted; | |
189 | ||
190 | private int ackMode; | |
191 | ||
192 | /** | |
193 | * Mnemonic identifier for defining a queue-session | |
194 | */ | |
195 | public final static String QUEUE_SESSION = "queue"; | |
196 | ||
197 | /** | |
198 | * Mnemonic identifier for defining a topic-session | |
199 | */ | |
200 | public final static String TOPIC_SESSION = "topic"; | |
201 | ||
202 | /** | |
203 | * Mnemonic identifier for defining a generic-session | |
204 | */ | |
205 | public final static String GENERIC_SESSION = "generic"; | |
206 | ||
207 | /** | |
208 | * Mnemonic identifier for defining an xa-session | |
209 | */ | |
210 | public final static String XA_SESSION = "xa"; | |
211 | ||
212 | /** | |
213 | * Mnemonic identifier for defining an xa-queue-session | |
214 | */ | |
215 | public final static String XA_QUEUE_SESSION = "xaQueue"; | |
216 | ||
217 | /** | |
218 | * Mnemonic identifier for defining an xa-topic-session | |
219 | */ | |
220 | public final static String XA_TOPIC_SESSION = "xaTopic"; | |
221 | } |
|