final Element gatewayNode = YADOMUtil.addElement(root, "listener");
gatewayNode.setAttribute("name", gateway.getName());
gatewayNode.setAttribute("gatewayClass", CamelGateway.class.getName());
final CamelBus bus;
try {
bus = (CamelBus)model.getOptionalBus(gateway.getBusidref());
} catch (ClassCastException e) {
throw new ConfigurationException("Invalid busid reference [" + gateway.getBusidref() + "] on gateway [" + gateway.getName() + "]. A <camel-gateway> must reference a <camel-bus>.");
}
List<String> routeXMLs = new ArrayList<String>();
URI toURI = createToURI(gateway, bus, model);
if (bus != null) {
try {
// <camel-bus from-uri="">
if (bus.isSetFromUri()) {
URI busFromURI = createURI(bus.getFromUri());
addRouteXML(busFromURI, toURI, routeXMLs);
}
// <camel-bus><from uri="">*
for (From busFrom : bus.getFromList()) {
URI fromURI = createURI(busFrom.getUri());
addRouteXML(fromURI, toURI, routeXMLs);
}
} catch (ClassCastException e) {
throw new ConfigurationException("Invalid bus config [" + gateway.getBusidref() + "]. Should be contained within a <camel-provider> instance. Unexpected exception - this should have caused a validation error!");