001 /**
002 *
003 * Copyright 2004 Hiram Chirino
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 *
017 **/
018 package org.activemq.ra;
019
020 import javax.resource.spi.ConnectionRequestInfo;
021 import java.io.Serializable;
022
023
024 /**
025 * @version $Revision: 1.1.1.1 $
026 *
027 * Must override equals and hashCode (JCA spec 16.4)
028 */
029 public class ActiveMQConnectionRequestInfo implements ConnectionRequestInfo, Serializable, Cloneable {
030
031 private static final long serialVersionUID = -5754338187296859149L;
032
033 private String userName;
034 private String password;
035 private String serverUrl;
036 private String clientid;
037 private Boolean useInboundSession;
038
039 public ActiveMQConnectionRequestInfo copy() {
040 try {
041 return (ActiveMQConnectionRequestInfo) clone();
042 }
043 catch (CloneNotSupportedException e) {
044 throw new RuntimeException("Could not clone: ", e);
045 }
046 }
047
048
049 /**
050 * @see javax.resource.spi.ConnectionRequestInfo#hashCode()
051 */
052 public int hashCode() {
053 int rc = 0;
054 if (useInboundSession != null) {
055 rc ^= useInboundSession.hashCode();
056 }
057 if (serverUrl != null) {
058 rc ^= serverUrl.hashCode();
059 }
060 return rc;
061 }
062
063
064 /**
065 * @see javax.resource.spi.ConnectionRequestInfo#equals(java.lang.Object)
066 */
067 public boolean equals(Object o) {
068 if (o == null) {
069 return false;
070 }
071 if (!getClass().equals(o.getClass())) {
072 return false;
073 }
074 ActiveMQConnectionRequestInfo i = (ActiveMQConnectionRequestInfo) o;
075 if ( notEqual(serverUrl, i.serverUrl) ) {
076 return false;
077 }
078 if ( notEqual(useInboundSession, i.useInboundSession) ) {
079 return false;
080 }
081 return true;
082 }
083
084
085 /**
086 * @param i
087 * @return
088 */
089 private boolean notEqual(Object o1, Object o2) {
090 return (o1 == null ^ o2 == null) || (o1 != null && !o1.equals(o2));
091 }
092
093 /**
094 * @return Returns the url.
095 */
096 public String getServerUrl() {
097 return serverUrl;
098 }
099
100 /**
101 * @param url The url to set.
102 */
103 public void setServerUrl(String url) {
104 this.serverUrl = url;
105 }
106
107 /**
108 * @return Returns the password.
109 */
110 public String getPassword() {
111 return password;
112 }
113
114 /**
115 * @param password The password to set.
116 */
117 public void setPassword(String password) {
118 this.password = password;
119 }
120
121 /**
122 * @return Returns the userid.
123 */
124 public String getUserName() {
125 return userName;
126 }
127
128 /**
129 * @param userid The userid to set.
130 */
131 public void setUserName(String userid) {
132 this.userName = userid;
133 }
134
135 /**
136 * @return Returns the clientid.
137 */
138 public String getClientid() {
139 return clientid;
140 }
141
142 /**
143 * @param clientid The clientid to set.
144 */
145 public void setClientid(String clientid) {
146 this.clientid = clientid;
147 }
148
149 public String toString() {
150 return "ActiveMQConnectionRequestInfo{ " +
151 "userName = '" + userName + "' " +
152 ", serverUrl = '" + serverUrl + "' " +
153 ", clientid = '" + clientid + "' " +
154 ", userName = '" + userName + "' " +
155 ", useInboundSession = '" + useInboundSession + "' " +
156 " }";
157 }
158
159
160 public Boolean getUseInboundSession() {
161 return useInboundSession;
162 }
163
164
165 public void setUseInboundSession(Boolean useInboundSession) {
166 this.useInboundSession = useInboundSession;
167 }
168
169
170 public boolean isUseInboundSessionEnabled() {
171 return useInboundSession!=null && useInboundSession.booleanValue();
172 }
173 }