1 /***
2 *
3 * Copyright 2004 Hiram Chirino
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 **/
18 package org.codehaus.activemq.ra;
19
20 import javax.resource.spi.ConnectionRequestInfo;
21 import java.io.Serializable;
22
23
24 /***
25 * @version $Revision: 1.6 $
26 */
27 public class ActiveMQConnectionRequestInfo implements ConnectionRequestInfo, Serializable, Cloneable {
28
29 private static final long serialVersionUID = -5754338187296859149L;
30
31 String userName;
32 String password;
33 String serverUrl;
34 String clientid;
35 boolean xa;
36
37
38 public ActiveMQConnectionRequestInfo copy() {
39 try {
40 return (ActiveMQConnectionRequestInfo) clone();
41 }
42 catch (CloneNotSupportedException e) {
43 throw new RuntimeException("Could not clone: ", e);
44 }
45 }
46
47
48 /***
49 * @see javax.resource.spi.ConnectionRequestInfo#hashCode()
50 */
51 public int hashCode() {
52 int rc = 0;
53 if (userName != null) {
54 rc ^= userName.hashCode();
55 }
56 if (password != null) {
57 rc ^= password.hashCode();
58 }
59 if (serverUrl != null) {
60 rc ^= serverUrl.hashCode();
61 }
62 if (clientid != null) {
63 rc ^= clientid.hashCode();
64 }
65 if (xa) {
66 rc ^= 0xabcdef;
67 }
68 return rc;
69 }
70
71
72 /***
73 * @see javax.resource.spi.ConnectionRequestInfo#equals(java.lang.Object)
74 */
75 public boolean equals(Object o) {
76 if (o == null) {
77 return false;
78 }
79 if (!getClass().equals(o.getClass())) {
80 return false;
81 }
82 ActiveMQConnectionRequestInfo i = (ActiveMQConnectionRequestInfo) o;
83 if (userName == null ^ i.userName == null) {
84 return false;
85 }
86 if (userName != null && !userName.equals(i.userName)) {
87 return false;
88 }
89 if (password == null ^ i.password == null) {
90 return false;
91 }
92 if (password != null && !password.equals(i.password)) {
93 return false;
94 }
95 if (serverUrl == null ^ i.serverUrl == null) {
96 return false;
97 }
98 if (serverUrl != null && !serverUrl.equals(i.serverUrl)) {
99 return false;
100 }
101 if (clientid == null ^ i.clientid == null) {
102 return false;
103 }
104 if (clientid != null && !clientid.equals(i.clientid)) {
105 return false;
106 }
107 if (xa != i.xa) {
108 return false;
109 }
110 return true;
111 }
112
113 /***
114 * @return Returns the url.
115 */
116 public String getServerUrl() {
117 return serverUrl;
118 }
119
120 /***
121 * @param url The url to set.
122 */
123 public void setServerUrl(String url) {
124 this.serverUrl = url;
125 }
126
127 /***
128 * @return Returns the password.
129 */
130 public String getPassword() {
131 return password;
132 }
133
134 /***
135 * @param password The password to set.
136 */
137 public void setPassword(String password) {
138 this.password = password;
139 }
140
141 /***
142 * @return Returns the userid.
143 */
144 public String getUserName() {
145 return userName;
146 }
147
148 /***
149 * @param userid The userid to set.
150 */
151 public void setUserName(String userid) {
152 this.userName = userid;
153 }
154
155 /***
156 * @return Returns the clientid.
157 */
158 public String getClientid() {
159 return clientid;
160 }
161
162 /***
163 * @param clientid The clientid to set.
164 */
165 public void setClientid(String clientid) {
166 this.clientid = clientid;
167 }
168
169 /***
170 * @return Is an XA connection to be created?
171 */
172 public boolean isXa() {
173 return xa;
174 }
175
176 /***
177 * Enables or disables whether XA connections should be created
178 */
179 public void setXa(boolean xa) {
180 this.xa = xa;
181 }
182
183 }