remove channel-resolver attribute
remove ChannelResolver awareness from router parsers and FactoryBean refactor 'channelIdentifierMap' -> 'channelMappings' and other clarity enhancements trim array tokens added AbstractMappingMessageRouter
This commit is contained in:
@@ -24,6 +24,7 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.integration.config.xml.AbstractRouterParser;
|
||||
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
|
||||
import org.springframework.integration.xml.router.XPathRouter;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -36,15 +37,13 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class XPathRouterParser extends AbstractRouterParser {
|
||||
|
||||
private XPathExpressionParser xpathParser = new XPathExpressionParser();
|
||||
private final XPathExpressionParser xpathParser = new XPathExpressionParser();
|
||||
|
||||
|
||||
@Override
|
||||
protected BeanDefinition doParseRouter(Element element, ParserContext parserContext) {
|
||||
BeanDefinitionBuilder xpathRouterBuilder = BeanDefinitionBuilder.genericBeanDefinition(
|
||||
"org.springframework.integration.xml.router.XPathRouter");
|
||||
NodeList xPathExpressionNodes = element.getElementsByTagNameNS(
|
||||
element.getNamespaceURI(), "xpath-expression");
|
||||
BeanDefinitionBuilder xpathRouterBuilder = BeanDefinitionBuilder.genericBeanDefinition(XPathRouter.class);
|
||||
NodeList xPathExpressionNodes = element.getElementsByTagNameNS(element.getNamespaceURI(), "xpath-expression");
|
||||
Assert.isTrue(xPathExpressionNodes.getLength() <= 1, "At most one xpath-expression child may be specified.");
|
||||
String xPathExpressionRef = element.getAttribute("xpath-expression-ref");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(xpathRouterBuilder, element, "evaluate-as-string");
|
||||
@@ -53,8 +52,7 @@ public class XPathRouterParser extends AbstractRouterParser {
|
||||
Assert.isTrue(xPathExpressionChildPresent ^ xPathReferencePresent,
|
||||
"Exactly one of 'xpath-expression' or 'xpath-expression-ref' is required.");
|
||||
if (xPathExpressionChildPresent) {
|
||||
BeanDefinition beanDefinition = this.xpathParser.parse(
|
||||
(Element) xPathExpressionNodes.item(0), parserContext);
|
||||
BeanDefinition beanDefinition = this.xpathParser.parse((Element) xPathExpressionNodes.item(0), parserContext);
|
||||
xpathRouterBuilder.addConstructorArgValue(beanDefinition);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,7 +22,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.router.AbstractMessageRouter;
|
||||
import org.springframework.integration.router.AbstractMappingMessageRouter;
|
||||
import org.springframework.integration.xml.DefaultXmlPayloadConverter;
|
||||
import org.springframework.integration.xml.XmlPayloadConverter;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -38,7 +38,7 @@ import org.w3c.dom.Node;
|
||||
* @author Jonas Partner
|
||||
* @author Oleg Zhurakousky
|
||||
*/
|
||||
public class XPathRouter extends AbstractMessageRouter {
|
||||
public class XPathRouter extends AbstractMappingMessageRouter {
|
||||
|
||||
private volatile NodeMapper<Object> nodeMapper = new TextContentNodeMapper();
|
||||
|
||||
@@ -113,10 +113,10 @@ public class XPathRouter extends AbstractMessageRouter {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<Object> getChannelIdentifiers(Message<?> message) {
|
||||
protected List<Object> getChannelKeys(Message<?> message) {
|
||||
Node node = this.converter.convertToNode(message.getPayload());
|
||||
if (this.evaluateAsString){
|
||||
return Collections.singletonList((Object)this.xPathExpression.evaluateAsString(node));
|
||||
if (this.evaluateAsString) {
|
||||
return Collections.singletonList((Object) this.xPathExpression.evaluateAsString(node));
|
||||
}
|
||||
else {
|
||||
return this.xPathExpression.evaluate(node, this.nodeMapper);
|
||||
|
||||
Reference in New Issue
Block a user