final List<BroadcastGroupConfiguration> newConfigs = new ArrayList<BroadcastGroupConfiguration>();
for(final BroadcastGroupConfiguration config : broadcastGroups) {
final String name = config.getName();
final String key = "broadcast" + name;
if (jgroupFactories.containsKey(key)) {
ChannelFactory channelFactory = jgroupFactories.get(key);
String channelName = jgroupsChannels.get(key);
JChannel channel = (JChannel) channelFactory.createChannel(channelName);
channels.put(channelName, channel);
newConfigs.add(BroadcastGroupAdd.createBroadcastGroupConfiguration(name, config, channel, channelName));
} else {
final SocketBinding binding = groupBindings.get(key);
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 String key = "discovery" + name;
DiscoveryGroupConfiguration config = null;
if (jgroupFactories.containsKey(key)) {
ChannelFactory channelFactory = jgroupFactories.get(key);
String channelName = jgroupsChannels.get(key);
JChannel channel = channels.get(channelName);
if (channel == null) {
channel = (JChannel) channelFactory.createChannel(key);
channels.put(channelName, channel);
}
config = DiscoveryGroupAdd.createDiscoveryGroupConfiguration(name, entry.getValue(), channel, channelName);
} else {
final SocketBinding binding = groupBindings.get(key);