ExtensionFactoryFinder extensionFacFinder = ExtensionFactoryFinder.getInstance();
public SynapseConfiguration getConfiguration(InputStream is) {
log.info("Generating the Synapse configuration model by parsing the XML configuration");
SynapseConfiguration config = new SynapseConfiguration();
OMElement root = null;
try {
root = new StAXOMBuilder(is).getDocumentElement();
} catch (XMLStreamException e) {
handleException("Error parsing Synapse configuration : " + e.getMessage(), e);
}
root.build();
OMContainer definitions = root.getFirstChildWithName(Constants.DEFINITIONS_ELT);
if (definitions != null) {
Iterator iter = definitions.getChildren();
while (iter.hasNext()) {
Object o = iter.next();
if (o instanceof OMElement) {
OMElement elt = (OMElement) o;
if (Constants.SEQUENCE_ELT.equals(elt.getQName())) {
defineSequence(config, elt);
} else if (Constants.ENDPOINT_ELT.equals(elt.getQName())) {
defineEndpoint(config, elt);
} else if (Constants.PROPERTY_ELT.equals(elt.getQName())) {
defineProperty(config, elt);
} else {
defineExtension(config, elt);
}
}
}
}
OMElement elem = root.getFirstChildWithName(Constants.RULES_ELT);
if (elem == null) {
handleException("A valid Synapse configuration MUST specify the main mediator using the <rules> element");
} else {
SynapseMediator sm = (SynapseMediator) MediatorFactoryFinder.getInstance().getMediator(elem);
if (sm.getList().isEmpty()) {
handleException("Invalid configuration, the main mediator specified by the <rules> element is empty");
} else {
config.setMainMediator(sm);
}
}
if (is != null) {
try {