INT-461: changed the order in which the constructor arguments for the *XPathMessageSelector are provided (to match the actual constructor), the current constructor resolution on bean creation is ambiguous.

This commit is contained in:
Marius Bogoevici
2008-11-07 14:47:20 +00:00
parent 7084378432
commit 33d3dc4601
2 changed files with 20 additions and 12 deletions

View File

@@ -16,18 +16,18 @@
package org.springframework.integration.xml.config;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.integration.xml.selector.BooleanTestXPathMessageSelector;
import org.springframework.integration.xml.selector.StringValueTestXPathMessageSelector;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
/**
* @author Jonas Partner
*/
@@ -57,6 +57,13 @@ public class XPathSelectorParser extends AbstractSingleBeanDefinitionParser {
boolean xPathReferencePresent = StringUtils.hasText(xPathExpressionRef);
Assert.isTrue(xPathExpressionChildPresent ^ xPathReferencePresent,
"Exactly one of 'xpath-expression' or 'xpath-expression-ref' is required.");
if (xPathExpressionChildPresent) {
BeanDefinition beanDefinition = xpathParser.parse((Element) xPathExpressionNodes.item(0), parserContext);
builder.addConstructorArgValue(beanDefinition);
}
else {
builder.addConstructorArgReference(xPathExpressionRef);
}
if (evaluationType.equals("boolean")) {
builder.getBeanDefinition().setBeanClass(BooleanTestXPathMessageSelector.class);
Assert.state(!StringUtils.hasText(stringTestValue),
@@ -72,13 +79,6 @@ public class XPathSelectorParser extends AbstractSingleBeanDefinitionParser {
throw new IllegalArgumentException("Unsupported value [" + evaluationType
+ "] for 'evaluation-result-type', expected boolean or string.");
}
if (xPathExpressionChildPresent) {
BeanDefinition beanDefinition = xpathParser.parse((Element) xPathExpressionNodes.item(0), parserContext);
builder.addConstructorArgValue(beanDefinition);
}
else {
builder.addConstructorArgReference(xPathExpressionRef);
}
}
}