in common/src/main/java/flex/messaging/config/ClientConfigurationParser.java [431:507]
private void service(Node service) {
// Validation
requiredAttributesOrElements(service, SERVICE_REQ_CHILDREN);
allowedAttributesOrElements(service, SERVICE_CHILDREN);
String id = getAttributeOrChildElement(service, ID_ATTR);
if (isValidID(id)) {
ServiceSettings serviceSettings = config.getServiceSettings(id);
if (serviceSettings == null) {
serviceSettings = new ServiceSettings(id);
// Service Properties
NodeList properties = selectNodeList(service, PROPERTIES_ELEMENT + "/*");
if (properties.getLength() > 0) {
ConfigMap map = properties(properties, getSourceFileOf(service));
serviceSettings.addProperties(map);
}
config.addServiceSettings(serviceSettings);
} else {
// Duplicate service definition '{0}'.
ConfigurationException e = new ConfigurationException();
e.setMessage(DUPLICATE_SERVICE_ERROR, new Object[]{id});
throw e;
}
// Service Class Name
String className = getAttributeOrChildElement(service, CLASS_ATTR);
if (className.length() > 0) {
serviceSettings.setClassName(className);
} else {
// Class not specified for {SERVICE_ELEMENT} '{id}'.
ConfigurationException ex = new ConfigurationException();
ex.setMessage(CLASS_NOT_SPECIFIED, new Object[]{SERVICE_ELEMENT, id});
throw ex;
}
//Service Message Types - deprecated
// Default Channels
Node defaultChannels = selectSingleNode(service, DEFAULT_CHANNELS_ELEMENT);
if (defaultChannels != null) {
allowedChildElements(defaultChannels, DEFAULT_CHANNELS_CHILDREN);
NodeList channels = selectNodeList(defaultChannels, CHANNEL_ELEMENT);
for (int c = 0; c < channels.getLength(); c++) {
Node chan = channels.item(c);
allowedAttributes(chan, new String[]{REF_ATTR});
defaultChannel(chan, serviceSettings);
}
}
// Fall back on application's default channels
else if (config.getDefaultChannels().size() > 0) {
for (Iterator iter = config.getDefaultChannels().iterator(); iter.hasNext(); ) {
String channelId = (String) iter.next();
ChannelSettings channel = config.getChannelSettings(channelId);
serviceSettings.addDefaultChannel(channel);
}
}
// Destinations
NodeList list = selectNodeList(service, DESTINATION_ELEMENT);
for (int i = 0; i < list.getLength(); i++) {
Node dest = list.item(i);
destination(dest, serviceSettings);
}
// Destination Includes
list = selectNodeList(service, DESTINATION_INCLUDE_ELEMENT);
for (int i = 0; i < list.getLength(); i++) {
Node dest = list.item(i);
destinationInclude(dest, serviceSettings);
}
} else {
//Invalid {SERVICE_ELEMENT} id '{id}'.
ConfigurationException ex = new ConfigurationException();
ex.setMessage(INVALID_ID, new Object[]{SERVICE_ELEMENT, id});
throw ex;
}
}