INT-2960 - Remove deprecated 'xpath-selector'

For reference see: https://jira.springsource.org/browse/INT-2960

* Remove 'xpath-selector' from XML Schema
* Remove parser class
* Remove tests
* Remove respective reference documentation
This commit is contained in:
Gunnar Hillert
2013-03-14 14:27:06 -04:00
committed by Gary Russell
parent cd7e0576ed
commit 26e41c8858
5 changed files with 0 additions and 210 deletions

View File

@@ -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());

View File

@@ -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.");
}
}
}

View File

@@ -658,39 +658,6 @@
</xsd:restriction>
</xsd:simpleType>
<xsd:element name="xpath-selector">
<xsd:annotation>
<xsd:documentation>
Defines an XPath selector.
NOTE: this element is deprecated as of 2.1. Please use &lt;xpath-filter&gt; instead.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="xpath-expression" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:string"/>
<xsd:attribute name="xpath-expression-ref" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type type="org.springframework.xml.xpath.XPathExpression"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="evaluation-result-type" use="required">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="boolean"/>
<xsd:enumeration value="string"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="string-test-value" type="xsd:string" use="optional"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="xpath-expression">
<xsd:annotation>
<xsd:documentation><![CDATA[

View File

@@ -1,81 +0,0 @@
/*
* Copyright 2002-2008 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 static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.w3c.dom.Document;
import org.springframework.integration.core.MessageSelector;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.xml.util.XmlTestUtil;
/**
* @author Jonas Partner
*/
public class XPathSelectorParserTests {
@Test
public void testSimpleStringExpressionBoolean() throws Exception {
String contextXml = "<si-xml:xpath-selector id='selector' evaluation-result-type='boolean' ><si-xml:xpath-expression expression='/name'/></si-xml:xpath-selector>";
MessageSelector selector =getSelector( contextXml);
assertTrue(selector.accept(new GenericMessage<Document>(XmlTestUtil.getDocumentForString("<name>outputOne</name>"))));
assertFalse(selector.accept(new GenericMessage<Document>(XmlTestUtil.getDocumentForString("<other>outputOne</other>"))));
}
@Test
public void testStringExpressionWithNamespaceBoolean() throws Exception {
String contextXml = "<si-xml:xpath-selector id='selector' evaluation-result-type='boolean'><si-xml:xpath-expression expression='/ns:name' ns-prefix='ns' ns-uri='www.example.org'/> </si-xml:xpath-selector>";
MessageSelector selector = getSelector(contextXml);
assertTrue(selector.accept(new GenericMessage<Document>(XmlTestUtil.getDocumentForString("<ns1:name xmlns:ns1='www.example.org'>outputOne</ns1:name>"))));
assertFalse(selector.accept(new GenericMessage<Document>(XmlTestUtil.getDocumentForString("<name>outputOne</name>"))));
}
@Test
public void testStringExpressionWithNamespaceString() throws Exception {
String contextXml = "<si-xml:xpath-selector id='selector' evaluation-result-type='string' string-test-value='outputOne'><si-xml:xpath-expression expression='/ns:name' ns-prefix='ns' ns-uri='www.example.org'/> </si-xml:xpath-selector>";
MessageSelector selector = getSelector(contextXml);
assertTrue(selector.accept(new GenericMessage<Document>(XmlTestUtil.getDocumentForString("<ns1:name xmlns:ns1='www.example.org'>outputOne</ns1:name>"))));
assertFalse(selector.accept(new GenericMessage<Document>(XmlTestUtil.getDocumentForString("<name>outputOne</name>"))));
}
@Test
public void testStringExpressionWithNestedMap() throws Exception {
StringBuffer contextXml = new StringBuffer("<si-xml:xpath-selector id='selector' evaluation-result-type='boolean'>");
contextXml.append("<si-xml:xpath-expression expression='/ns:name' >")
.append("<map><entry key='ns' value='www.example.org' /></map>")
.append("</si-xml:xpath-expression></si-xml:xpath-selector>");
MessageSelector selector = getSelector(contextXml.toString());
assertTrue(selector.accept(new GenericMessage<Document>(XmlTestUtil.getDocumentForString("<ns1:name xmlns:ns1='www.example.org'>outputOne</ns1:name>"))));
assertFalse(selector.accept(new GenericMessage<Document>(XmlTestUtil.getDocumentForString("<name>outputOne</name>"))));
}
public MessageSelector getSelector( String testcontextXml) throws Exception{
TestXmlApplicationContext ctx =
TestXmlApplicationContextHelper.getTestAppContext(testcontextXml);
return (MessageSelector) ctx.getBean("selector");
}
}

View File

@@ -1150,17 +1150,6 @@
thos <code>match-value</code> attribute must be a valid Regular Expression.
</para>
<note>
In prior versions of Spring Integration the functionality of the XPath Filter
was configured using the <code>xpath-selector</code> element. However, in order
to provide a more consistent behavior within the Spring Integration Framework,
<emphasis role="bold">the <code>xpath-selector</code> element is deprecated as of version 2.1</emphasis>.
Please use <code>&lt;xpath-filter&gt;</code> instead. It provides the same
set of functionality. In fact it still uses the same <code>MessageSelectors</code>
internally.
</note>
<programlisting language="xml"><![CDATA[<int-xml:xpath-filter discard-channel="" ]]><co id="xpath-filter-xml01-co" linkends="xpath-filter-xml01" /><![CDATA[
id="" ]]><co id="xpath-filter-xml02-co" linkends="xpath-filter-xml02" /><![CDATA[
input-channel="" ]]><co id="xpath-filter-xml03-co" linkends="xpath-filter-xml03" /><![CDATA[