public com.sun.corba.ee.spi.transport.SocketInfo | getEndPointInfo(org.omg.CORBA.ORB orb, com.sun.corba.ee.spi.ior.IOR ior, com.sun.corba.ee.spi.transport.SocketInfo endPointInfo)
try {
IIOPProfileTemplate temp = (IIOPProfileTemplate)ior.
getProfile().getTaggedProfileTemplate();
IIOPAddress primary = temp.getPrimaryAddress() ;
String host = primary.getHost().toLowerCase();
int port = primary.getPort();
if(_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE,"ENDPOINT INFO:host=" +host + ", port=" + port);
}
// If there is already a cached EndPointImpl for the primary host and
// port return that.
if ((endPointInfo = (EndPointInfoImpl)endpointTable.get(host + port)) != null)
return endPointInfo;
TaggedComponent alternateAddressTaggedComponents[] =
ior.getProfile().getTaggedProfileTemplate().
getIOPComponents((com.sun.corba.ee.spi.orb.ORB)orb,
org.omg.IOP.TAG_ALTERNATE_IIOP_ADDRESS.value
//AlternateIIOPAddressComponent.TAG_ALTERNATE_IIOP_ADDRESS_ID
);
if (alternateAddressTaggedComponents.length > 0) {
getCodec(orb);
for (int i = 0; i < alternateAddressTaggedComponents.length; i++) {
byte[] data = alternateAddressTaggedComponents[i].component_data;
Any any = null;
try {
any = codec.decode_value(data,
AlternateIIOPAddressComponentHelper.type());
} catch (org.omg.IOP.CodecPackage.TypeMismatch e) {
if (_logger.isLoggable(Level.FINE)){
_logger.log(Level.FINE,"Exception codec TypeMismatch",e);
}
throw new RuntimeException(e.toString());
} catch (org.omg.IOP.CodecPackage.FormatMismatch e) {
if (_logger.isLoggable(Level.FINE) ){
_logger.log(Level.FINE,"Exception codec FormatMismatch",e);
}
throw new RuntimeException(e.toString());
}
AlternateIIOPAddressComponent iiopAddress =
AlternateIIOPAddressComponentHelper.extract(any);
// if any host:port has an EndPointImpl in the endpointTable
// we should make sure we set the primary host:port with
// that EndPointImpl in the endpointTable and return that.
// Subsequently we will not even get here, since for the
// primary host:port the cached value will be returned
if ((endPointInfo = (EndPointInfoImpl)endpointTable.
get(iiopAddress.host + iiopAddress.port)) != null) {
/*
if (!type.equals(ORBSocketFactory.IIOP_CLEAR_TEXT)) {
// Use this host address to make the connection, since a connection
// has already been made using this address, just use the secure port.
// It is assumed that the primary host address in the IOR is also
// one of the taggeded alternate addresses, which is a fair assumption.
// Hence the remote machine should be reacheable thru the cached
// host address and new secure port being specified
endPointInfo = new EndPointInfoImpl(type, iiopAddress.host, port);
endpointTable.put(host + port, endPointInfo);
return endPointInfo;
} else { */
endpointTable.put(host + port, endPointInfo);
return endPointInfo;
//}
}
}
// In case nothing is found use primary host:port
endPointInfo = new EndPointInfoImpl(ORBSocketFactory.IIOP_CLEAR_TEXT, port, host);
endpointTable.put(host + port, endPointInfo);
} else {
endPointInfo = new EndPointInfoImpl(ORBSocketFactory.IIOP_CLEAR_TEXT, port, host);
endpointTable.put(host + port, endPointInfo);
}
return endPointInfo;
} catch ( Exception ex ) {
if (_logger.isLoggable(Level.FINE)){
_logger.log(Level.FINE,"Exception getting End point info",ex);
}
throw new RuntimeException(ex.getMessage());
}
|