001 /**
002 *
003 * Copyright 2004 Protique Ltd
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
019 package org.activemq.message;
020
021 import java.io.Serializable;
022 import java.util.Properties;
023
024 /**
025 * Describes a Connection
026 *
027 * @version $Revision: 1.1.1.1 $
028 */
029
030 public class ConnectionInfo extends AbstractPacket implements Serializable{
031 /**
032 * Hint for transport(s) about message delivery
033 */
034 public static String NO_DELAY_PROPERTY = "noDelay";
035 static final long serialVersionUID = 55678222l;
036 String clientId;
037 String userName;
038 String password;
039 String hostName;
040 String clientVersion;
041 int wireFormatVersion;
042 long startTime;
043 boolean started;
044 boolean closed;
045 Properties properties = new Properties();
046
047
048 /**
049 * Return the type of Packet
050 *
051 * @return integer representation of the type of Packet
052 */
053
054 public int getPacketType() {
055 return ACTIVEMQ_CONNECTION_INFO;
056 }
057
058 /**
059 * Test for equality
060 *
061 * @param obj object to test
062 * @return true if equivalent
063 */
064 public boolean equals(Object obj) {
065 boolean result = false;
066 if (obj != null && obj instanceof ConnectionInfo) {
067 ConnectionInfo info = (ConnectionInfo) obj;
068 result = this.clientId.equals(info.clientId);
069 }
070 return result;
071 }
072
073 /**
074 * @return hash code for instance
075 */
076 public int hashCode() {
077 return this.clientId != null ? this.clientId.hashCode() : super.hashCode();
078 }
079
080
081 /**
082 * @return Returns the clientId.
083 */
084 public String getClientId() {
085 return this.clientId;
086 }
087
088 /**
089 * @param newClientId The clientId to set.
090 */
091 public void setClientId(String newClientId) {
092 this.clientId = newClientId;
093 }
094
095 /**
096 * @return Returns the hostName.
097 */
098 public String getHostName() {
099 return this.hostName;
100 }
101
102 /**
103 * @param newHostName The hostName to set.
104 */
105 public void setHostName(String newHostName) {
106 this.hostName = newHostName;
107 }
108
109 /**
110 * @return Returns the password.
111 */
112 public String getPassword() {
113 return this.password;
114 }
115
116 /**
117 * @param newPassword The password to set.
118 */
119 public void setPassword(String newPassword) {
120 this.password = newPassword;
121 }
122
123 /**
124 * @return Returns the properties.
125 */
126 public Properties getProperties() {
127 return this.properties;
128 }
129
130 /**
131 * @param newProperties The properties to set.
132 */
133 public void setProperties(Properties newProperties) {
134 this.properties = newProperties;
135 }
136
137 /**
138 * @return Returns the startTime.
139 */
140 public long getStartTime() {
141 return this.startTime;
142 }
143
144 /**
145 * @param newStartTime The startTime to set.
146 */
147 public void setStartTime(long newStartTime) {
148 this.startTime = newStartTime;
149 }
150
151 /**
152 * @return Returns the userName.
153 */
154 public String getUserName() {
155 return this.userName;
156 }
157
158 /**
159 * @param newUserName The userName to set.
160 */
161 public void setUserName(String newUserName) {
162 this.userName = newUserName;
163 }
164
165 /**
166 * @return Returns the started.
167 */
168 public boolean isStarted() {
169 return started;
170 }
171
172 /**
173 * @param started The started to set.
174 */
175 public void setStarted(boolean started) {
176 this.started = started;
177 }
178
179 /**
180 * @return Returns the closed.
181 */
182 public boolean isClosed() {
183 return closed;
184 }
185
186 /**
187 * @param closed The closed to set.
188 */
189 public void setClosed(boolean closed) {
190 this.closed = closed;
191 }
192 /**
193 * @return Returns the clientVersion.
194 */
195 public String getClientVersion() {
196 return clientVersion;
197 }
198 /**
199 * @param clientVersion The clientVersion to set.
200 */
201 public void setClientVersion(String clientVersion) {
202 this.clientVersion = clientVersion;
203 }
204 /**
205 * @return Returns the wireFormatVersion.
206 */
207 public int getWireFormatVersion() {
208 return wireFormatVersion;
209 }
210 /**
211 * @param wireFormatVersion The wireFormatVersion to set.
212 */
213 public void setWireFormatVersion(int wireFormatVersion) {
214 this.wireFormatVersion = wireFormatVersion;
215 }
216
217
218 public String toString() {
219 return super.toString() + " ConnectionInfo{ " +
220 "clientId = '" + clientId + "' " +
221 ", userName = '" + userName + "' " +
222 ", hostName = '" + hostName + "' " +
223 ", clientVersion = '" + clientVersion + "' " +
224 ", wireFormatVersion = " + wireFormatVersion +
225 ", startTime = " + startTime +
226 ", started = " + started +
227 ", closed = " + closed +
228 ", properties = " + properties +
229 " }";
230 }
231 }