private static final QName TRY_Q = new QName(Constants.SYNAPSE_NAMESPACE, "try");
public Mediator createMediator(OMElement elem) {
TryMediator tryMediator = new TryMediator();
// process sequence of the try mediator
OMElement seq = elem.getFirstChildWithName(
new QName(Constants.SYNAPSE_NAMESPACE, "sequence"));
if (seq != null) {
super.addChildren(seq, tryMediator);
} else {
handleException("A 'sequence' element is required for a 'try' mediator");
}
// process onError mediators
OMElement error = elem.getFirstChildWithName(
new QName(Constants.SYNAPSE_NAMESPACE, "onError"));
if (error != null) {
Iterator it = error.getChildElements();
while (it.hasNext()) {
OMElement child = (OMElement) it.next();
Mediator med = MediatorFactoryFinder.getInstance().getMediator(child);
if (med != null) {
tryMediator.getErrorHandlerMediators().add(med);
} else {
handleException("Unknown mediator : " + child.getLocalName());
}
}
} else {
handleException("A 'onError' element is required for a 'try' mediator");
}
// process finally mediators - if any
OMElement fin = elem.getFirstChildWithName(
new QName(Constants.SYNAPSE_NAMESPACE, "finally"));
if (fin != null) {
Iterator it = fin.getChildElements();
while (it.hasNext()) {
OMElement child = (OMElement) it.next();
Mediator med = MediatorFactoryFinder.getInstance().getMediator(child);
if (med != null) {
tryMediator.getFinallyMediators().add(med);
} else {
handleException("Unknown mediator : " + child.getLocalName());
}
}
}