}
Iterator itr = elem.getChildrenWithName(ROUTE_Q);
while (itr.hasNext()) {
OMElement routeElem = (OMElement) itr.next();
ConditionalRoute conditionalRoute = new ConditionalRoute();
if (routeElem.getAttribute(BREAK_ROUTE_ATTR) != null) {
if (JavaUtils.isTrueExplicitly(
routeElem.getAttributeValue(BREAK_ROUTE_ATTR).trim())) {
conditionalRoute.setBreakRoute(true);
} else if (JavaUtils.isFalseExplicitly(
routeElem.getAttributeValue(BREAK_ROUTE_ATTR).trim())) {
conditionalRoute.setBreakRoute(false);
} else {
handleException("breakRoute attribute value of the conditionalRoute element must " +
"be either 'true' or 'false', the value found is : "
+ routeElem.getAttributeValue(BREAK_ROUTE_ATTR).trim());
}
}
OMElement conditionElem = routeElem.getFirstChildWithName(CONDITION_Q);
if (conditionElem == null) {
handleException("Couldn't find the condition of the conditional router");
return null;
}
try {
Evaluator evaluator = EvaluatorFactoryFinder.getInstance().getEvaluator(
conditionElem.getFirstElement());
conditionalRoute.setEvaluator(evaluator);
} catch (EvaluatorException ee) {
handleException("Couldn't build the condition of the conditional router", ee);
}
OMElement targetElem = routeElem.getFirstChildWithName(TARGET_Q);
Target target = TargetFactory.createTarget(targetElem, properties);
if (JavaUtils.isTrueExplicitly(routeElem.getAttributeValue(ASYNCHRONOUS_ATTR))) {
target.setAsynchronous(true);
} else {
target.setAsynchronous(false);
}
conditionalRoute.setTarget(target);
conditionalRouterMediator.addRoute(conditionalRoute);
}
return conditionalRouterMediator;
}