private static final QName FORMAT_Q = new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "format");
private static final QName ARGS_Q = new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "args");
public Mediator createSpecificMediator(OMElement elem, Properties properties) {
PayloadFactoryMediator payloadFactoryMediator = new PayloadFactoryMediator();
OMElement formatElem = elem.getFirstChildWithName(FORMAT_Q);
if (formatElem != null) {
OMElement copy = formatElem.getFirstElement().cloneOMElement();
removeIndentations(copy);
payloadFactoryMediator.setFormat(copy.toString());
} else {
handleException("format element of payloadFactoryMediator is required");
}
OMElement argumentsElem = elem.getFirstChildWithName(ARGS_Q);
if (argumentsElem != null) {
Iterator itr = argumentsElem.getChildElements();
while (itr.hasNext()) {
OMElement argElem = (OMElement) itr.next();
PayloadFactoryMediator.Argument arg = new PayloadFactoryMediator.Argument();
String value;
if ((value = argElem.getAttributeValue(ATT_VALUE)) != null) {
arg.setValue(value);
} else if ((value = argElem.getAttributeValue(ATT_EXPRN)) != null) {
if (value.trim().length() == 0) {
handleException("Value of 'expression' attribute is required");
} else {
try {
arg.setExpression(SynapseXPathFactory.getSynapseXPath(argElem, ATT_EXPRN));
} catch (JaxenException e) {
handleException("Invalid XPath expression is provided for " +
"'expression' attribute: " + value, e);
}
}
} else {
handleException("Unsupported arg type. 'value' or 'expression' attribute is " +
"required");
}
payloadFactoryMediator.addArgument(arg);
}
}
return payloadFactoryMediator;
}