remove xquery and xpath expressions we arent using, drop xalan build dependency
Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/8633f4f7 Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/8633f4f7 Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/8633f4f7 Branch: refs/heads/master Commit: 8633f4f7e8c33152fa95e3e2ef8b1dbb0e504f17 Parents: 8540359 Author: Robert Gemmell <rob...@apache.org> Authored: Tue Mar 3 11:40:03 2015 +0000 Committer: Robert Gemmell <rob...@apache.org> Committed: Tue Mar 3 11:47:33 2015 +0000 ---------------------------------------------------------------------- qpid-jms-client/pom.xml | 9 -- .../jms/selector/filter/UnaryExpression.java | 8 -- .../jms/selector/filter/XPathExpression.java | 78 ------------- .../jms/selector/filter/XQueryExpression.java | 50 -------- .../selector/filter/XalanXPathEvaluator.java | 115 ------------------- qpid-jms-client/src/main/javacc/StrictParser.jj | 12 -- .../qpid/jms/selector/SelectorParserTest.java | 7 -- .../apache/qpid/jms/selector/SelectorTest.java | 41 ------- 8 files changed, 320 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/8633f4f7/qpid-jms-client/pom.xml ---------------------------------------------------------------------- diff --git a/qpid-jms-client/pom.xml b/qpid-jms-client/pom.xml index d2c4813..39e2c39 100644 --- a/qpid-jms-client/pom.xml +++ b/qpid-jms-client/pom.xml @@ -72,15 +72,6 @@ <artifactId>hamcrest-all</artifactId> <scope>test</scope> </dependency> - - <!-- =================================== --> - <!-- Build Dependencies --> - <!-- =================================== --> - <dependency> - <groupId>xalan</groupId> - <artifactId>xalan</artifactId> - <optional>true</optional> - </dependency> </dependencies> <build> http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/8633f4f7/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/filter/UnaryExpression.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/filter/UnaryExpression.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/filter/UnaryExpression.java index 1233447..854a659 100755 --- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/filter/UnaryExpression.java +++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/filter/UnaryExpression.java @@ -151,14 +151,6 @@ public abstract class UnaryExpression implements Expression { }; } - public static BooleanExpression createXPath(final String xpath) { - return new XPathExpression(xpath); - } - - public static BooleanExpression createXQuery(final String xpath) { - return new XQueryExpression(xpath); - } - public static BooleanExpression createBooleanCast(Expression left) { return new BooleanUnaryExpression(left) { @Override http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/8633f4f7/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/filter/XPathExpression.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/filter/XPathExpression.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/filter/XPathExpression.java deleted file mode 100755 index ebfc38f..0000000 --- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/filter/XPathExpression.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.qpid.jms.selector.filter; - -/** - * Used to evaluate an XPath Expression in a JMS selector. - */ -public final class XPathExpression implements BooleanExpression { - - public static XPathEvaluatorFactory XPATH_EVALUATOR_FACTORY = null; - static { - // Install the xalan xpath evaluator if it available. - new XalanXPathEvaluator("//root").evaluate("<root></root>"); - try { - XPATH_EVALUATOR_FACTORY = new XPathExpression.XPathEvaluatorFactory() { - @Override - public XPathExpression.XPathEvaluator create(String xpath) { - return new XalanXPathEvaluator(xpath); - } - }; - } catch(Throwable e) { - } - } - - private final String xpath; - private final XPathEvaluator evaluator; - - public static interface XPathEvaluatorFactory { - XPathEvaluator create(String xpath); - } - - public static interface XPathEvaluator { - boolean evaluate(Filterable message) throws FilterException; - } - - XPathExpression(String xpath) { - if( XPATH_EVALUATOR_FACTORY == null ) { - throw new IllegalArgumentException("XPATH support not enabled."); - } - this.xpath = xpath; - this.evaluator = XPATH_EVALUATOR_FACTORY.create(xpath); - } - - @Override - public Object evaluate(Filterable message) throws FilterException { - return evaluator.evaluate(message) ? Boolean.TRUE : Boolean.FALSE; - } - - @Override - public String toString() { - return "XPATH " + ConstantExpression.encodeString(xpath); - } - - /** - * @param message - * @return true if the expression evaluates to Boolean.TRUE. - * @throws FilterException - */ - @Override - public boolean matches(Filterable message) throws FilterException { - Object object = evaluate(message); - return object != null && object == Boolean.TRUE; - } -} http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/8633f4f7/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/filter/XQueryExpression.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/filter/XQueryExpression.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/filter/XQueryExpression.java deleted file mode 100755 index 00d091c..0000000 --- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/filter/XQueryExpression.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.qpid.jms.selector.filter; - -/** - * Used to evaluate an XQuery Expression in a JMS selector. - */ -public final class XQueryExpression implements BooleanExpression { - private final String xpath; - - XQueryExpression(String xpath) { - super(); - this.xpath = xpath; - } - - @Override - public Object evaluate(Filterable message) throws FilterException { - return Boolean.FALSE; - } - - @Override - public String toString() { - return "XQUERY " + ConstantExpression.encodeString(xpath); - } - - /** - * @param message - * @return true if the expression evaluates to Boolean.TRUE. - * @throws FilterException - */ - @Override - public boolean matches(Filterable message) throws FilterException { - Object object = evaluate(message); - return object != null && object == Boolean.TRUE; - } -} http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/8633f4f7/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/filter/XalanXPathEvaluator.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/filter/XalanXPathEvaluator.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/filter/XalanXPathEvaluator.java deleted file mode 100644 index 13ad667..0000000 --- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/filter/XalanXPathEvaluator.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.qpid.jms.selector.filter; - -import java.io.StringReader; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.apache.xpath.CachedXPathAPI; -import org.apache.xpath.objects.XObject; -import org.w3c.dom.Document; -import org.w3c.dom.traversal.NodeIterator; -import org.xml.sax.InputSource; - -public class XalanXPathEvaluator implements XPathExpression.XPathEvaluator { - public static final String DOCUMENT_BUILDER_FACTORY_FEATURE = "org.apache.activemq.apollo.documentBuilderFactory.feature"; - private final String xpath; - - public XalanXPathEvaluator(String xpath) { - this.xpath = xpath; - } - - @Override - public boolean evaluate(Filterable m) throws FilterException { - String stringBody = m.getBodyAs(String.class); - if (stringBody!=null) { - return evaluate(stringBody); - } - return false; - } - - protected boolean evaluate(String text) { - return evaluate(new InputSource(new StringReader(text))); - } - - protected boolean evaluate(InputSource inputSource) { - try { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - factory.setFeature("http://xml.org/sax/features/external-general-entities", false); - factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false); - factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - setupFeatures(factory); - factory.setNamespaceAware(true); - factory.setIgnoringElementContentWhitespace(true); - factory.setIgnoringComments(true); - DocumentBuilder dbuilder = factory.newDocumentBuilder(); - Document doc = dbuilder.parse(inputSource); - - // An XPath expression could return a true or false value instead of a node. - // eval() is a better way to determine the boolean value of the exp. - // For compliance with legacy behavior where selecting an empty node returns true, - // selectNodeIterator is attempted in case of a failure. - - CachedXPathAPI cachedXPathAPI = new CachedXPathAPI(); - XObject result = cachedXPathAPI.eval(doc, xpath); - if (result.bool()) { - return true; - } else { - NodeIterator iterator = cachedXPathAPI.selectNodeIterator(doc, xpath); - return (iterator.nextNode() != null); - } - } catch (Throwable e) { - return false; - } - } - - protected void setupFeatures(DocumentBuilderFactory factory) { - Properties properties = System.getProperties(); - List<String> features = new ArrayList<String>(); - for (Map.Entry<Object, Object> prop : properties.entrySet()) { - String key = (String) prop.getKey(); - if (key.startsWith(DOCUMENT_BUILDER_FACTORY_FEATURE)) { - String uri = key.split(DOCUMENT_BUILDER_FACTORY_FEATURE + ":")[1]; - Boolean value = Boolean.valueOf((String)prop.getValue()); - try { - factory.setFeature(uri, value); - features.add("feature " + uri + " value " + value); - } catch (ParserConfigurationException e) { - throw new RuntimeException("DocumentBuilderFactory doesn't support the feature " + uri + " with value " + value + ", due to " + e); - } - } - } - - if (features.size() > 0) { - StringBuffer featureString = new StringBuffer(); - // just log the configured feature - for (String feature : features) { - if (featureString.length() != 0) { - featureString.append(", "); - } - featureString.append(feature); - } - } - } -} http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/8633f4f7/qpid-jms-client/src/main/javacc/StrictParser.jj ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/main/javacc/StrictParser.jj b/qpid-jms-client/src/main/javacc/StrictParser.jj index b095209..bf1bec5 100755 --- a/qpid-jms-client/src/main/javacc/StrictParser.jj +++ b/qpid-jms-client/src/main/javacc/StrictParser.jj @@ -108,8 +108,6 @@ TOKEN [IGNORE_CASE] : | < TRUE : "TRUE" > | < FALSE : "FALSE" > | < NULL : "NULL" > - | < XPATH : "XPATH" > - | < XQUERY : "XQUERY" > } /* Literals */ @@ -419,16 +417,6 @@ Expression unaryExpr() : left = UnaryExpression.createNOT( asBooleanExpression(left) ); } | - <XPATH> s=stringLitteral() - { - left = UnaryExpression.createXPath( s ); - } - | - <XQUERY> s=stringLitteral() - { - left = UnaryExpression.createXQuery( s ); - } - | left = primaryExpr() ) { http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/8633f4f7/qpid-jms-client/src/test/java/org/apache/qpid/jms/selector/SelectorParserTest.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/selector/SelectorParserTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/selector/SelectorParserTest.java index c0e73c2..73eca85 100755 --- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/selector/SelectorParserTest.java +++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/selector/SelectorParserTest.java @@ -24,19 +24,12 @@ import org.apache.qpid.jms.selector.filter.ComparisonExpression; import org.apache.qpid.jms.selector.filter.Expression; import org.apache.qpid.jms.selector.filter.LogicExpression; import org.apache.qpid.jms.selector.filter.PropertyExpression; -import org.apache.qpid.jms.selector.filter.XPathExpression; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class SelectorParserTest extends TestCase { private static final Logger LOG = LoggerFactory.getLogger(SelectorParserTest.class); - public void testParseXPath() throws Exception { - BooleanExpression filter = parse("XPATH '//title[@lang=''eng'']'"); - assertTrue("Created XPath expression", filter instanceof XPathExpression); - LOG.info("Expression: " + filter); - } - public void testParseWithParensAround() throws Exception { String[] values = {"x = 1 and y = 2", "(x = 1) and (y = 2)", "((x = 1) and (y = 2))"}; http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/8633f4f7/qpid-jms-client/src/test/java/org/apache/qpid/jms/selector/SelectorTest.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/selector/SelectorTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/selector/SelectorTest.java index a103f9a..bc59301 100755 --- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/selector/SelectorTest.java +++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/selector/SelectorTest.java @@ -121,47 +121,6 @@ public class SelectorTest extends TestCase { assertSelector(message, "(trueProp OR falseProp) AND falseProp", false); } - public void testXPathSelectors() throws Exception { - MockMessage message = new MockMessage(); - - message.setJMSType("xml"); - message.setText("<root><a key='first' num='1'/><b key='second' num='2'>b</b></root>"); - - assertSelector(message, "XPATH 'root/a'", true); - assertSelector(message, "XPATH '//root/b'", true); - assertSelector(message, "XPATH 'root/c'", false); - assertSelector(message, "XPATH '//root/b/text()=\"b\"'", true); - assertSelector(message, "XPATH '//root/b=\"b\"'", true); - assertSelector(message, "XPATH '//root/b=\"c\"'", false); - assertSelector(message, "XPATH '//root/b!=\"c\"'", true); - - assertSelector(message, "XPATH '//root/*[@key=''second'']'", true); - assertSelector(message, "XPATH '//root/*[@key=''third'']'", false); - assertSelector(message, "XPATH '//root/a[@key=''first'']'", true); - assertSelector(message, "XPATH '//root/a[@num=1]'", true); - assertSelector(message, "XPATH '//root/a[@key=''second'']'", false); - - assertSelector(message, "XPATH '/root/*[@key=''first'' or @key=''third'']'", true); - assertSelector(message, "XPATH '//root/*[@key=''third'' or @key=''forth'']'", false); - - assertSelector(message, "XPATH '/root/b=''b'' and /root/b[@key=''second'']'", true); - assertSelector(message, "XPATH '/root/b=''b'' and /root/b[@key=''first'']'", false); - - assertSelector(message, "XPATH 'not(//root/a)'", false); - assertSelector(message, "XPATH 'not(//root/c)'", true); - assertSelector(message, "XPATH '//root/a[not(@key=''first'')]'", false); - assertSelector(message, "XPATH '//root/a[not(not(@key=''first''))]'", true); - - assertSelector(message, "XPATH 'string(//root/b)'", true); - assertSelector(message, "XPATH 'string(//root/a)'", false); - - assertSelector(message, "XPATH 'sum(//@num) < 10'", true); - assertSelector(message, "XPATH 'sum(//@num) > 10'", false); - - assertSelector(message, "XPATH '//root/a[@num > 1]'", false); - assertSelector(message, "XPATH '//root/b[@num > 1]'", true); - } - public void testJMSPropertySelectors() throws Exception { MockMessage message = createMessage(); message.setJMSType("selector-test"); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org