in core/src/main/java/flex/messaging/MessageBroker.java [835:898]
public ConfigMap describeServices(Endpoint endpoint, boolean onlyReliable) {
// Let the service validation listeners know about the configuration change.
if (!serviceValidationListeners.isEmpty()) {
for (Enumeration<ServiceValidationListener> iter = serviceValidationListeners.elements(); iter.hasMoreElements(); )
iter.nextElement().validateServices();
}
ConfigMap servicesConfig = new ConfigMap();
// Keep track of channel ids as we encounter them so we can generate
// the channel properties that might be needed by the client.
ArrayList<String> channelIds = new ArrayList<String>();
if (endpoint == null) {
for (Endpoint endpointToAdd : getEndpoints().values())
channelIds.add(endpointToAdd.getId());
} else {
channelIds.add(endpoint.getId());
}
if (defaultChannels != null) {
ConfigMap defaultChannelsMap = new ConfigMap();
for (Object defaultChannel : defaultChannels) {
String id = (String) defaultChannel;
ConfigMap channelConfig = new ConfigMap();
channelConfig.addProperty(ConfigurationConstants.REF_ATTR, id);
defaultChannelsMap.addProperty(ConfigurationConstants.CHANNEL_ELEMENT, channelConfig);
if (!channelIds.contains(id))
channelIds.add(id);
}
if (defaultChannelsMap.size() > 0)
servicesConfig.addProperty(ConfigurationConstants.DEFAULT_CHANNELS_ELEMENT, defaultChannelsMap);
}
for (Service service : services.values()) {
ConfigMap serviceConfig = service instanceof AbstractService ?
((AbstractService) service).describeService(endpoint, onlyReliable) : service.describeService(endpoint);
if (serviceConfig != null && serviceConfig.size() > 0)
servicesConfig.addProperty(ConfigurationConstants.SERVICE_ELEMENT, serviceConfig);
}
// Need to send channel properties again in case the client didn't
// compile in services-config.xml and hence doesn't have channels section
// of the configuration - but only if channel/endpoint is not tagged as "remote"!
ConfigMap channels = new ConfigMap();
for (String id : channelIds) {
Endpoint currentEndpoint = getEndpoint(id);
if (currentEndpoint instanceof AbstractEndpoint && ((AbstractEndpoint) currentEndpoint).isRemote()) {
continue; // Client already has configuration for "remote" endpoint by other means.
}
ConfigMap channel = currentEndpoint.describeEndpoint();
if (channel != null && channel.size() > 0)
channels.addProperty(ConfigurationConstants.CHANNEL_ELEMENT, channel);
}
if (channels.size() > 0)
servicesConfig.addProperty(ConfigurationConstants.CHANNELS_ELEMENT, channels);
if (Log.isDebug())
Log.getLogger(ConfigurationManager.LOG_CATEGORY).debug(
"Returning service description for endpoint: " +
(endpoint == null ? "all" : endpoint.getId()) + " config: " + servicesConfig);
return servicesConfig;
}