1 22 package org.jboss.mq; 23 24 import java.io.Serializable ; 25 26 import org.jboss.mq.il.ClientIL; 27 28 40 public class ConnectionToken implements Serializable 41 { 42 44 45 private static final long serialVersionUID = 1344893519455875890L; 46 47 49 53 public ClientIL clientIL; 54 55 58 protected String clientID; 59 60 64 private String sessionId; 65 66 67 private int hash; 68 69 71 73 79 public ConnectionToken(String clientID, ClientIL clientIL) 80 { 81 this.clientIL = clientIL; 82 setClientID(clientID); 83 } 84 85 92 public ConnectionToken(String clientID, ClientIL clientIL, String sessionId) 93 { 94 this(clientID, clientIL); 95 this.sessionId = sessionId; 96 } 97 98 100 105 public String getClientID() 106 { 107 return clientID; 108 } 109 110 115 public void setClientID(String clientID) 116 { 117 this.clientID = clientID; 118 if (clientID == null) 119 hash = 0; 120 else 121 hash = clientID.hashCode(); 122 } 123 124 129 public String getSessionId() 130 { 131 return sessionId; 132 } 133 134 136 public boolean equals(Object obj) 137 { 138 if (!(obj instanceof ConnectionToken) || obj == null) 139 return false; 140 141 if (obj.hashCode() != hash) 142 return false; 143 String yourID = ((ConnectionToken) obj).clientID; 144 String yourSessionId = ((ConnectionToken) obj).sessionId; 145 if (clientID == null && yourID != null) 146 return false; 147 else if (sessionId == null && yourSessionId != null) 148 return false; 149 else if (clientID != null && clientID.equals(yourID) == false) 150 return false; 151 else if (sessionId != null && sessionId.equals(yourSessionId) == false) 152 return false; 153 else 154 return true; 155 } 156 157 public int hashCode() 158 { 159 return hash; 160 } 161 162 public String toString() 163 { 164 return "ConnectionToken:" + clientID + "/" + sessionId; 165 } 166 167 169 171 173 } | Popular Tags |