1 7 8 package com.sun.corba.se.impl.transport; 9 10 import com.sun.corba.se.pept.transport.Connection; 11 12 import com.sun.corba.se.spi.ior.IOR ; 13 import com.sun.corba.se.spi.orb.ORB; 14 import com.sun.corba.se.spi.transport.CorbaContactInfoList; 15 import com.sun.corba.se.spi.transport.CorbaTransportManager; 16 import com.sun.corba.se.spi.transport.SocketInfo; 17 18 import com.sun.corba.se.impl.orbutil.ORBUtility; 19 import com.sun.corba.se.impl.transport.CorbaContactInfoBase; 20 21 24 public class SocketOrChannelContactInfoImpl 25 extends CorbaContactInfoBase 26 implements SocketInfo 27 { 28 protected boolean isHashCodeCached = false; 29 protected int cachedHashCode; 30 31 protected String socketType; 32 protected String hostname; 33 protected int port; 34 35 protected SocketOrChannelContactInfoImpl() 40 { 41 } 42 43 protected SocketOrChannelContactInfoImpl( 44 ORB orb, 45 CorbaContactInfoList contactInfoList) 46 { 47 this.orb = orb; 48 this.contactInfoList = contactInfoList; 49 } 50 51 public SocketOrChannelContactInfoImpl( 52 ORB orb, 53 CorbaContactInfoList contactInfoList, 54 String socketType, 55 String hostname, 56 int port) 57 { 58 this(orb, contactInfoList); 59 this.socketType = socketType; 60 this.hostname = hostname; 61 this.port = port; 62 } 63 64 public SocketOrChannelContactInfoImpl( 66 ORB orb, 67 CorbaContactInfoList contactInfoList, 68 IOR effectiveTargetIOR, 69 short addressingDisposition, 70 String socketType, 71 String hostname, 72 int port) 73 { 74 this(orb, contactInfoList, socketType, hostname, port); 75 this.effectiveTargetIOR = effectiveTargetIOR; 76 this.addressingDisposition = addressingDisposition; 77 } 78 79 84 public boolean isConnectionBased() 85 { 86 return true; 87 } 88 89 public boolean shouldCacheConnection() 90 { 91 return true; 92 } 93 94 public String getConnectionCacheType() 95 { 96 return CorbaTransportManager.SOCKET_OR_CHANNEL_CONNECTION_CACHE; 97 } 98 99 public Connection createConnection() 100 { 101 Connection connection = 102 new SocketOrChannelConnectionImpl(orb, this, 103 socketType, hostname, port); 104 return connection; 105 } 106 107 112 public String getMonitoringName() 113 { 114 return "SocketConnections"; 115 } 116 117 122 public String getType() 123 { 124 return socketType; 125 } 126 127 public String getHost() 128 { 129 return hostname; 130 } 131 132 public int getPort() 133 { 134 return port; 135 } 136 137 142 public int hashCode() 143 { 144 if (! isHashCodeCached) { 145 cachedHashCode = socketType.hashCode() ^ hostname.hashCode() ^ port; 146 isHashCodeCached = true; 147 } 148 return cachedHashCode; 149 } 150 151 public boolean equals(Object obj) 152 { 153 if (obj == null) { 154 return false; 155 } else if (!(obj instanceof SocketOrChannelContactInfoImpl)) { 156 return false; 157 } 158 159 SocketOrChannelContactInfoImpl other = 160 (SocketOrChannelContactInfoImpl) obj; 161 162 if (port != other.port) { 163 return false; 164 } 165 if (!hostname.equals(other.hostname)) { 166 return false; 167 } 168 if (socketType == null) { 169 if (other.socketType != null) { 170 return false; 171 } 172 } else if (!socketType.equals(other.socketType)) { 173 return false; 174 } 175 return true; 176 } 177 178 public String toString() 179 { 180 return 181 "SocketOrChannelContactInfoImpl[" 182 + socketType + " " 183 + hostname + " " 184 + port 185 + "]"; 186 } 187 188 193 protected void dprint(String msg) 194 { 195 ORBUtility.dprint("SocketOrChannelContactInfoImpl", msg); 196 } 197 } 198 199 | Popular Tags |