View Javadoc

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  
22  
23  /***
24   * @version $Revision: 1.5 $
25   */
26  public class ActiveMQConnectionRequestInfo implements ConnectionRequestInfo, Cloneable {
27  
28      String userName;
29      String password;
30      String serverUrl;
31      String clientid;
32      boolean xa;
33  
34  
35      public ActiveMQConnectionRequestInfo copy() {
36          try {
37              return (ActiveMQConnectionRequestInfo) clone();
38          }
39          catch (CloneNotSupportedException e) {
40              throw new RuntimeException("Could not clone: ", e);
41          }
42      }
43  
44  
45      /***
46       * @see javax.resource.spi.ConnectionRequestInfo#hashCode()
47       */
48      public int hashCode() {
49          int rc = 0;
50          if (userName != null) {
51              rc ^= userName.hashCode();
52          }
53          if (password != null) {
54              rc ^= password.hashCode();
55          }
56          if (serverUrl != null) {
57              rc ^= serverUrl.hashCode();
58          }
59          if (clientid != null) {
60              rc ^= clientid.hashCode();
61          }
62          if (xa) {
63              rc ^= 0xabcdef;
64          }
65          return rc;
66      }
67  
68  
69      /***
70       * @see javax.resource.spi.ConnectionRequestInfo#equals(java.lang.Object)
71       */
72      public boolean equals(Object o) {
73          if (o == null) {
74              return false;
75          }
76          if (!getClass().equals(o.getClass())) {
77              return false;
78          }
79          ActiveMQConnectionRequestInfo i = (ActiveMQConnectionRequestInfo) o;
80          if (userName == null ^ i.userName == null) {
81              return false;
82          }
83          if (userName != null && !userName.equals(i.userName)) {
84              return false;
85          }
86          if (password == null ^ i.password == null) {
87              return false;
88          }
89          if (password != null && !password.equals(i.password)) {
90              return false;
91          }
92          if (serverUrl == null ^ i.serverUrl == null) {
93              return false;
94          }
95          if (serverUrl != null && !serverUrl.equals(i.serverUrl)) {
96              return false;
97          }
98          if (clientid == null ^ i.clientid == null) {
99              return false;
100         }
101         if (clientid != null && !clientid.equals(i.clientid)) {
102             return false;
103         }
104         if (xa != i.xa) {
105             return false;
106         }
107         return true;
108     }
109 
110     /***
111      * @return Returns the url.
112      */
113     public String getServerUrl() {
114         return serverUrl;
115     }
116 
117     /***
118      * @param url The url to set.
119      */
120     public void setServerUrl(String url) {
121         this.serverUrl = url;
122     }
123 
124     /***
125      * @return Returns the password.
126      */
127     public String getPassword() {
128         return password;
129     }
130 
131     /***
132      * @param password The password to set.
133      */
134     public void setPassword(String password) {
135         this.password = password;
136     }
137 
138     /***
139      * @return Returns the userid.
140      */
141     public String getUserName() {
142         return userName;
143     }
144 
145     /***
146      * @param userid The userid to set.
147      */
148     public void setUserName(String userid) {
149         this.userName = userid;
150     }
151 
152     /***
153      * @return Returns the clientid.
154      */
155     public String getClientid() {
156         return clientid;
157     }
158 
159     /***
160      * @param clientid The clientid to set.
161      */
162     public void setClientid(String clientid) {
163         this.clientid = clientid;
164     }
165 
166     /***
167      * @return Is an XA connection to be created?
168      */
169     public boolean isXa() {
170         return xa;
171     }
172 
173     /***
174      * Enables or disables whether XA connections should be created
175      */
176     public void setXa(boolean xa) {
177         this.xa = xa;
178     }
179 
180 }