* @param properties properties passed
* @return IterateMediator created from the given configuration
*/
public Mediator createSpecificMediator(OMElement elem, Properties properties) {
IterateMediator mediator = new IterateMediator();
processAuditStatus(mediator, elem);
OMAttribute id = elem.getAttribute(ID_Q);
if (id != null) {
mediator.setId(id.getAttributeValue());
}
OMAttribute continueParent = elem.getAttribute(ATT_CONTPAR);
if (continueParent != null) {
mediator.setContinueParent(
Boolean.valueOf(continueParent.getAttributeValue()));
}
OMAttribute preservePayload = elem.getAttribute(ATT_PREPLD);
if (preservePayload != null) {
mediator.setPreservePayload(
Boolean.valueOf(preservePayload.getAttributeValue()));
}
OMAttribute expression = elem.getAttribute(ATT_EXPRN);
if (expression != null) {
try {
mediator.setExpression(SynapseXPathFactory.getSynapseXPath(elem, ATT_EXPRN));
} catch (JaxenException e) {
handleException("Unable to build the IterateMediator. " + "Invalid XPATH " +
expression.getAttributeValue(), e);
}
} else {
handleException("XPATH expression is required " +
"for an IterateMediator under the \"expression\" attribute");
}
OMAttribute attachPath = elem.getAttribute(ATT_ATTACHPATH);
String attachPathValue = ".";
if (attachPath != null && !mediator.isPreservePayload()) {
handleException("Wrong configuration for the iterate mediator :: if the iterator " +
"should not preserve payload, then attachPath can not be present");
} else if (attachPath != null) {
attachPathValue = attachPath.getAttributeValue();
}
try {
SynapseXPath xp = new SynapseXPath(attachPathValue);
OMElementUtils.addNameSpaces(xp, elem, log);
mediator.setAttachPath(xp);
} catch (JaxenException e) {
handleException("Unable to build the IterateMediator. Invalid XPATH " +
attachPathValue, e);
}
boolean asynchronous = true;
OMAttribute asynchronousAttr = elem.getAttribute(ATT_SEQUENCIAL);
if (asynchronousAttr != null && asynchronousAttr.getAttributeValue().equals("true")) {
asynchronous = false;
}
OMElement targetElement = elem.getFirstChildWithName(TARGET_Q);
if (targetElement != null) {
Target target = TargetFactory.createTarget(targetElement, properties);
if (target != null) {
target.setAsynchronous(asynchronous);
mediator.setTarget(target);
}
} else {
handleException("Target for an iterate mediator is required :: missing target");
}