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();
host = sa.getAddress().getHostName();
port = sa.getPort();
} else {
host = binding.getDestinationAddress().getHostName();
port = binding.getDestinationPort();
}
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());
}
tc.getParams().put(HOST, binding.getSocketAddress().getHostName());
tc.getParams().put(PORT, "" + binding.getSocketAddress().getPort());
}
}
}
if(broadcastGroups != null) {
final List<BroadcastGroupConfiguration> newConfigs = new ArrayList<BroadcastGroupConfiguration>();
for(final BroadcastGroupConfiguration config : broadcastGroups) {
final String name = config.getName();
final SocketBinding binding = groupBindings.get("broadcast" + name);
if (binding == null) {
throw MESSAGES.failedToFindBroadcastSocketBinding(name);
}
newConfigs.add(BroadcastGroupAdd.createBroadcastGroupConfiguration(name, config, binding));
}
configuration.getBroadcastGroupConfigurations().clear();
configuration.getBroadcastGroupConfigurations().addAll(newConfigs);
}
if(discoveryGroups != null) {
configuration.setDiscoveryGroupConfigurations(new HashMap<String, DiscoveryGroupConfiguration>());
for(final Map.Entry<String, DiscoveryGroupConfiguration> entry : discoveryGroups.entrySet()) {
final String name = entry.getKey();
final SocketBinding binding = groupBindings.get("discovery" + name);
if (binding == null) {
throw MESSAGES.failedToFindDiscoverySocketBinding(name);
}
final DiscoveryGroupConfiguration config = DiscoveryGroupAdd.createDiscoveryGroupConfiguration(name, entry.getValue(), binding);
configuration.getDiscoveryGroupConfigurations().put(name, config);