* @return The ConfigTree listener configuration node.
* @throws org.jboss.soa.esb.ConfigurationException Invalid listener configuration.
*/
public static Element map(Element root, FsListener listener, XMLBeansModel model) throws ConfigurationException {
Element listenerNode = YADOMUtil.addElement(root, "listener");
FsBus bus;
FsProvider provider;
listenerNode.setAttribute("name", listener.getName());
try {
bus = (FsBus) model.getBus(listener.getBusidref());
} catch (ClassCastException e) {
throw new ConfigurationException("Invalid busid reference [" + listener.getBusidref() + "] on listener [" + listener.getName() + "]. A <fs-listener> must reference a <fs-bus>.");
}
try {
provider = (FsProvider) model.getProvider(bus);
} catch (ClassCastException e) {
throw new ConfigurationException("Invalid bus config [" + listener.getBusidref() + "]. Should be contained within a <fs-provider> instance. Unexpected exception - this should have caused a validation error!");
}
FsMessageFilter messageFilter = listener.getFsMessageFilter();
if(messageFilter == null) {
messageFilter = bus.getFsMessageFilter();
if(messageFilter == null) {
throw new ConfigurationException("No <fs-detination> defined on either <fs-listener> [" + listener.getName() + "] or <fs-bus> [" + bus.getBusid() + "].");
}
}
// Map the standard listener attributes - common across all listener types...
MapperUtil.mapDefaultAttributes(listener, listenerNode, model);
// Map the <property> elements targeted at the listener - from the listener itself.