private static final QName ASYNCHRONOUS_ATTR
= new QName(XMLConfigConstants.NULL_NAMESPACE, "asynchronous");
public Mediator createSpecificMediator(OMElement elem, Properties properties) {
ConditionalRouterMediator conditionalRouterMediator = new ConditionalRouterMediator();
processAuditStatus(conditionalRouterMediator, elem);
if (elem.getAttribute(CONTINUE_AFTER_ATTR) != null) {
if (JavaUtils.isTrueExplicitly(elem.getAttributeValue(CONTINUE_AFTER_ATTR).trim())) {
conditionalRouterMediator.setContinueAfter(true);
} else if (JavaUtils.isFalseExplicitly(
elem.getAttributeValue(CONTINUE_AFTER_ATTR).trim())) {
conditionalRouterMediator.setContinueAfter(false);
} else {
handleException("continueAfter attribute value of the conditionalRouter must " +
"be either 'true' or 'false', the value found is : "
+ elem.getAttributeValue(CONTINUE_AFTER_ATTR).trim());
}
}
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;
}