1 22 package org.jboss.invocation.pooled.interfaces; 23 24 import java.io.Serializable ; 25 import java.io.IOException ; 26 import javax.net.SocketFactory; 27 28 39 public class ServerAddress implements Serializable 40 { 41 42 private static final long serialVersionUID = -7206359745950445445L; 43 44 48 public String address; 49 50 54 public int port; 55 56 60 public boolean enableTcpNoDelay = false; 61 62 66 public int timeout = 60000; 67 70 public SocketFactory clientSocketFactory; 71 72 76 private transient int hashCode; 77 78 87 public ServerAddress(String address, int port, boolean enableTcpNoDelay, 88 int timeout, SocketFactory clientSocketFactory) 89 { 90 this.address = address; 91 this.port = port; 92 this.enableTcpNoDelay = enableTcpNoDelay; 93 this.hashCode = address.hashCode() + port; 94 if( enableTcpNoDelay ) 95 this.hashCode ++; 96 this.timeout = timeout; 97 this.clientSocketFactory = clientSocketFactory; 98 } 99 100 public String toString() 101 { 102 return "[address:" + address + ",port:" + port + ",enableTcpNoDelay:" + enableTcpNoDelay + "]"; 103 } 104 105 public boolean equals(Object obj) 106 { 107 try 108 { 109 ServerAddress o = (ServerAddress) obj; 111 if (port != o.port) 112 return false; 113 if (address.equals(o.address) == false) 114 return false; 115 if (enableTcpNoDelay != o.enableTcpNoDelay) 116 return false; 117 return true; 118 } 119 catch (Throwable e) 120 { 121 return false; 122 } 123 } 124 125 public int hashCode() 126 { 127 return hashCode; 128 } 129 130 136 private void readObject(java.io.ObjectInputStream in) 137 throws IOException , ClassNotFoundException 138 { 139 in.defaultReadObject(); 141 this.hashCode = address.hashCode() + port; 143 if( enableTcpNoDelay ) 144 this.hashCode ++; 145 } 146 } 147 | Popular Tags |