Object socketRef = tc.getParams().remove(SOCKET_REF);
if (socketRef != null) {
String name = socketRef.toString();
String host;
int port;
OutboundSocketBinding binding = outboundSocketBindings.get(name);
if (binding == null) {
final SocketBinding socketBinding = socketBindings.get(name);
if (socketBinding == null) {
throw MESSAGES.failedToFindConnectorSocketBinding(tc.getName());
}
InetSocketAddress sa = socketBinding.getSocketAddress();
port = sa.getPort();
// resolve the host name of the address only if a loopback adress has been set
if (sa.getAddress().isLoopbackAddress()) {
host = sa.getAddress().getHostName();
} else {
host = sa.getAddress().getHostAddress();
}
} else {
port = binding.getDestinationPort();
if (binding.getDestinationAddress().isLoopbackAddress()) {
host = binding.getDestinationAddress().getHostName();
} else {
host = binding.getDestinationAddress().getHostAddress();
}
}
tc.getParams().put(HOST, host);
tc.getParams().put(PORT, String.valueOf(port));
}
}
}
if (acceptors != null) {
for (TransportConfiguration tc : acceptors) {
// If there is a socket binding set the HOST/PORT values
Object socketRef = tc.getParams().remove(SOCKET_REF);
if (socketRef != null) {
String name = socketRef.toString();
SocketBinding binding = socketBindings.get(name);
if (binding == null) {
throw MESSAGES.failedToFindConnectorSocketBinding(tc.getName());
}
InetSocketAddress socketAddress = binding.getSocketAddress();
tc.getParams().put(HOST, socketAddress.getAddress().getHostAddress());
tc.getParams().put(PORT, "" + socketAddress.getPort());
}
}
}