diff --git a/spring-integration-xml/src/main/java/org/springframework/integration/xml/config/IntegrationXmlNamespaceHandler.java b/spring-integration-xml/src/main/java/org/springframework/integration/xml/config/IntegrationXmlNamespaceHandler.java index e584f99201..5ba56dce75 100644 --- a/spring-integration-xml/src/main/java/org/springframework/integration/xml/config/IntegrationXmlNamespaceHandler.java +++ b/spring-integration-xml/src/main/java/org/springframework/integration/xml/config/IntegrationXmlNamespaceHandler.java @@ -32,7 +32,6 @@ public class IntegrationXmlNamespaceHandler extends AbstractIntegrationNamespace registerBeanDefinitionParser("xpath-header-enricher", new XPathHeaderEnricherParser()); registerBeanDefinitionParser("xpath-router", new XPathRouterParser()); registerBeanDefinitionParser("xpath-filter", new XPathFilterParser()); - registerBeanDefinitionParser("xpath-selector", new XPathSelectorParser()); registerBeanDefinitionParser("xpath-expression", new XPathExpressionParser()); registerBeanDefinitionParser("xpath-splitter", new XPathMessageSplitterParser()); registerBeanDefinitionParser("validating-filter", new XmlPayloadValidatingFilterParser()); diff --git a/spring-integration-xml/src/main/java/org/springframework/integration/xml/config/XPathSelectorParser.java b/spring-integration-xml/src/main/java/org/springframework/integration/xml/config/XPathSelectorParser.java deleted file mode 100644 index c63b3dd6c2..0000000000 --- a/spring-integration-xml/src/main/java/org/springframework/integration/xml/config/XPathSelectorParser.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2002-2010 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -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.integration.xml.selector.BooleanTestXPathMessageSelector; -import org.springframework.integration.xml.selector.StringValueTestXPathMessageSelector; -import org.springframework.util.Assert; -import org.springframework.util.StringUtils; - -/** - * @author Jonas Partner - */ -public class XPathSelectorParser extends AbstractSingleBeanDefinitionParser { - - private XPathExpressionParser xpathParser = new XPathExpressionParser(); - - - @Override - protected boolean shouldGenerateId() { - return false; - } - - @Override - protected boolean shouldGenerateIdAsFallback() { - return true; - } - - @Override - protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { - String evaluationType = element.getAttribute("evaluation-result-type"); - String xPathExpressionRef = element.getAttribute("xpath-expression-ref"); - String stringTestValue = element.getAttribute("string-test-value"); - NodeList xPathExpressionNodes = element.getElementsByTagNameNS(element.getNamespaceURI(), "xpath-expression"); - Assert.isTrue(xPathExpressionNodes.getLength() <= 1, "At most one xpath-expression child may be specified."); - boolean xPathExpressionChildPresent = xPathExpressionNodes.getLength() == 1; - 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), - "'string-test-value' should not be specified when 'evaluation-result-type' is boolean"); - } - else if (evaluationType.equals("string")) { - Assert.hasText(stringTestValue, - "'string-test-value' must be specified when 'evaluation-result-type' is string"); - builder.addConstructorArgValue(stringTestValue); - builder.getBeanDefinition().setBeanClass(StringValueTestXPathMessageSelector.class); - } - else { - throw new IllegalArgumentException("Unsupported value [" + evaluationType - + "] for 'evaluation-result-type', expected boolean or string."); - } - } - -} diff --git a/spring-integration-xml/src/main/resources/org/springframework/integration/xml/config/spring-integration-xml-3.0.xsd b/spring-integration-xml/src/main/resources/org/springframework/integration/xml/config/spring-integration-xml-3.0.xsd index 0793863f75..ae605e70ca 100644 --- a/spring-integration-xml/src/main/resources/org/springframework/integration/xml/config/spring-integration-xml-3.0.xsd +++ b/spring-integration-xml/src/main/resources/org/springframework/integration/xml/config/spring-integration-xml-3.0.xsd @@ -658,39 +658,6 @@ - - - - Defines an XPath selector. - NOTE: this element is deprecated as of 2.1. Please use <xpath-filter> instead. - - - - - - - - - - - - - - - - - - - - - - - - - - - - "; - MessageSelector selector =getSelector( contextXml); - - assertTrue(selector.accept(new GenericMessage(XmlTestUtil.getDocumentForString("outputOne")))); - assertFalse(selector.accept(new GenericMessage(XmlTestUtil.getDocumentForString("outputOne")))); - } - - @Test - public void testStringExpressionWithNamespaceBoolean() throws Exception { - String contextXml = " "; - MessageSelector selector = getSelector(contextXml); - assertTrue(selector.accept(new GenericMessage(XmlTestUtil.getDocumentForString("outputOne")))); - assertFalse(selector.accept(new GenericMessage(XmlTestUtil.getDocumentForString("outputOne")))); - } - - @Test - public void testStringExpressionWithNamespaceString() throws Exception { - String contextXml = " "; - MessageSelector selector = getSelector(contextXml); - - assertTrue(selector.accept(new GenericMessage(XmlTestUtil.getDocumentForString("outputOne")))); - assertFalse(selector.accept(new GenericMessage(XmlTestUtil.getDocumentForString("outputOne")))); - } - - @Test - public void testStringExpressionWithNestedMap() throws Exception { - StringBuffer contextXml = new StringBuffer(""); - contextXml.append("") - .append("") - .append(""); - MessageSelector selector = getSelector(contextXml.toString()); - - assertTrue(selector.accept(new GenericMessage(XmlTestUtil.getDocumentForString("outputOne")))); - assertFalse(selector.accept(new GenericMessage(XmlTestUtil.getDocumentForString("outputOne")))); - - } - - - public MessageSelector getSelector( String testcontextXml) throws Exception{ - TestXmlApplicationContext ctx = - TestXmlApplicationContextHelper.getTestAppContext(testcontextXml); - return (MessageSelector) ctx.getBean("selector"); - - } - -} diff --git a/src/reference/docbook/xml.xml b/src/reference/docbook/xml.xml index ffdad3c1bd..228cce5516 100644 --- a/src/reference/docbook/xml.xml +++ b/src/reference/docbook/xml.xml @@ -1150,17 +1150,6 @@ thos match-value attribute must be a valid Regular Expression. - - In prior versions of Spring Integration the functionality of the XPath Filter - was configured using the xpath-selector element. However, in order - to provide a more consistent behavior within the Spring Integration Framework, - the xpath-selector element is deprecated as of version 2.1. - - Please use <xpath-filter> instead. It provides the same - set of functionality. In fact it still uses the same MessageSelectors - internally. - -