INT-1377, added support for dynamics in XML XPath router, added mapping support for XPath router configuration

This commit is contained in:
Oleg Zhurakousky
2010-10-13 16:16:48 -04:00
parent 5b6a96c34f
commit 6c053a9e11
5 changed files with 136 additions and 14 deletions

View File

@@ -16,16 +16,21 @@
package org.springframework.integration.xml.config;
import java.util.List;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.ManagedMap;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.config.xml.AbstractConsumerEndpointParser;
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.util.xml.DomUtils;
/**
* Parser for the <xpath-router/> element.
@@ -63,6 +68,19 @@ public class XPathRouterParser extends AbstractConsumerEndpointParser {
String classname = "org.springframework.integration.xml.router." +
((multiChannel) ? "XPathMultiChannelRouter" : "XPathSingleChannelRouter");
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(classname);
List<Element> childElements = DomUtils.getChildElementsByTagName(element, "mapping");
if (childElements != null && childElements.size() > 0) {
ManagedMap<String, String> channelMap = new ManagedMap<String, String>();
for (Element childElement : childElements) {
String key = childElement.getAttribute("value");
channelMap.put(key, childElement.getAttribute("channel"));
}
builder.addPropertyValue("channelIdentifierMap", channelMap);
}
if (xPathExpressionChildPresent) {
BeanDefinition beanDefinition = this.xpathParser.parse(
(Element) xPathExpressionNodes.item(0), parserContext);

View File

@@ -352,6 +352,21 @@
<xsd:sequence>
<xsd:element ref="xpath-expression" minOccurs="0" maxOccurs="1"/>
<xsd:element ref="integration:poller" minOccurs="0" maxOccurs="1"/>
<xsd:element name="mapping" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:attribute name="value" type="xsd:string" />
<xsd:attribute name="channel" type="xsd:string">
<xsd:annotation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type
type="org.springframework.integration.core.MessageChannel" />
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:ID"/>
<xsd:attribute name="input-channel" type="xsd:string">