From 2b11b8c36d29bc5f444b081fdf54e3974c5468a1 Mon Sep 17 00:00:00 2001 From: "Jonas B. Lim" Date: Tue, 26 Sep 2006 09:49:55 +0000 Subject: [PATCH] fix for https://issues.apache.org/activemq/browse/AMQ-851 - reduce dependencies of the activemq-core POM to only minimal stuff. moved xpath filtering components to activemq-optional git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@449965 13f79535-47bb-0310-9956-ffa450edef68 --- activemq-core/pom.xml | 25 --- activemq-optional/pom.xml | 31 ++++ .../activemq/filter/JAXPXPathEvaluator.java | 156 +++++++++--------- .../filter/XMLBeansXPathEvaluator.java | 124 +++++++------- 4 files changed, 171 insertions(+), 165 deletions(-) rename {activemq-core => activemq-optional}/src/main/java/org/apache/activemq/filter/JAXPXPathEvaluator.java (97%) mode change 100755 => 100644 rename {activemq-core => activemq-optional}/src/main/java/org/apache/activemq/filter/XMLBeansXPathEvaluator.java (97%) mode change 100755 => 100644 diff --git a/activemq-core/pom.xml b/activemq-core/pom.xml index 883de44015..388eb65277 100755 --- a/activemq-core/pom.xml +++ b/activemq-core/pom.xml @@ -137,26 +137,6 @@ smackx true - - xmlbeans - xbean - true - - - xmlbeans - xmlpublic - true - - - xmlbeans - xbean_xpath - true - - - stax - stax-api - true - stax stax @@ -174,11 +154,6 @@ xalan true - - activesoap - jaxp-api - test - org.apache.xbean xbean-spring diff --git a/activemq-optional/pom.xml b/activemq-optional/pom.xml index 1aaf0aacc2..179e5cd021 100755 --- a/activemq-optional/pom.xml +++ b/activemq-optional/pom.xml @@ -104,8 +104,39 @@ junit compile + + + xmlbeans + xbean + true + + + + xmlbeans + xmlpublic + true + + + xmlbeans + xbean_xpath + true + + + + xalan + xalan + true + + + stax + stax-api + true + + + + diff --git a/activemq-core/src/main/java/org/apache/activemq/filter/JAXPXPathEvaluator.java b/activemq-optional/src/main/java/org/apache/activemq/filter/JAXPXPathEvaluator.java old mode 100755 new mode 100644 similarity index 97% rename from activemq-core/src/main/java/org/apache/activemq/filter/JAXPXPathEvaluator.java rename to activemq-optional/src/main/java/org/apache/activemq/filter/JAXPXPathEvaluator.java index 5627fe00dc..89b72214da --- a/activemq-core/src/main/java/org/apache/activemq/filter/JAXPXPathEvaluator.java +++ b/activemq-optional/src/main/java/org/apache/activemq/filter/JAXPXPathEvaluator.java @@ -1,78 +1,78 @@ -/** - * - * 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.activemq.filter; - -import java.io.StringReader; - -import javax.jms.BytesMessage; -import javax.jms.JMSException; -import javax.jms.TextMessage; -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathExpressionException; -import javax.xml.xpath.XPathFactory; - -import org.apache.activemq.command.Message; -import org.apache.activemq.util.ByteArrayInputStream; -import org.xml.sax.InputSource; - -public class JAXPXPathEvaluator implements XPathExpression.XPathEvaluator { - - private static final XPathFactory factory = XPathFactory.newInstance(); - private javax.xml.xpath.XPathExpression expression; - - public JAXPXPathEvaluator(String xpathExpression) { - try { - XPath xpath = factory.newXPath(); - expression = xpath.compile(xpathExpression); - } catch (XPathExpressionException e) { - throw new RuntimeException("Invalid XPath expression: "+xpathExpression); - } - } - - public boolean evaluate(Message message) throws JMSException { - if( message instanceof TextMessage ) { - String text = ((TextMessage)message).getText(); - return evaluate(text); - } else if ( message instanceof BytesMessage ) { - BytesMessage bm = (BytesMessage) message; - byte data[] = new byte[(int) bm.getBodyLength()]; - bm.readBytes(data); - return evaluate(data); - } - return false; - } - - private boolean evaluate(byte[] data) { - try { - InputSource inputSource = new InputSource(new ByteArrayInputStream(data)); - return ((Boolean)expression.evaluate(inputSource, XPathConstants.BOOLEAN)).booleanValue(); - } catch (XPathExpressionException e) { - return false; - } - } - - private boolean evaluate(String text) { - try { - InputSource inputSource = new InputSource(new StringReader(text)); - return ((Boolean)expression.evaluate(inputSource, XPathConstants.BOOLEAN)).booleanValue(); - } catch (XPathExpressionException e) { - return false; - } - } -} +/** + * + * 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.activemq.filter; + +import java.io.StringReader; + +import javax.jms.BytesMessage; +import javax.jms.JMSException; +import javax.jms.TextMessage; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathExpressionException; +import javax.xml.xpath.XPathFactory; + +import org.apache.activemq.command.Message; +import org.apache.activemq.util.ByteArrayInputStream; +import org.xml.sax.InputSource; + +public class JAXPXPathEvaluator implements XPathExpression.XPathEvaluator { + + private static final XPathFactory factory = XPathFactory.newInstance(); + private javax.xml.xpath.XPathExpression expression; + + public JAXPXPathEvaluator(String xpathExpression) { + try { + XPath xpath = factory.newXPath(); + expression = xpath.compile(xpathExpression); + } catch (XPathExpressionException e) { + throw new RuntimeException("Invalid XPath expression: "+xpathExpression); + } + } + + public boolean evaluate(Message message) throws JMSException { + if( message instanceof TextMessage ) { + String text = ((TextMessage)message).getText(); + return evaluate(text); + } else if ( message instanceof BytesMessage ) { + BytesMessage bm = (BytesMessage) message; + byte data[] = new byte[(int) bm.getBodyLength()]; + bm.readBytes(data); + return evaluate(data); + } + return false; + } + + private boolean evaluate(byte[] data) { + try { + InputSource inputSource = new InputSource(new ByteArrayInputStream(data)); + return ((Boolean)expression.evaluate(inputSource, XPathConstants.BOOLEAN)).booleanValue(); + } catch (XPathExpressionException e) { + return false; + } + } + + private boolean evaluate(String text) { + try { + InputSource inputSource = new InputSource(new StringReader(text)); + return ((Boolean)expression.evaluate(inputSource, XPathConstants.BOOLEAN)).booleanValue(); + } catch (XPathExpressionException e) { + return false; + } + } +} diff --git a/activemq-core/src/main/java/org/apache/activemq/filter/XMLBeansXPathEvaluator.java b/activemq-optional/src/main/java/org/apache/activemq/filter/XMLBeansXPathEvaluator.java old mode 100755 new mode 100644 similarity index 97% rename from activemq-core/src/main/java/org/apache/activemq/filter/XMLBeansXPathEvaluator.java rename to activemq-optional/src/main/java/org/apache/activemq/filter/XMLBeansXPathEvaluator.java index fa23036daf..de67910e70 --- a/activemq-core/src/main/java/org/apache/activemq/filter/XMLBeansXPathEvaluator.java +++ b/activemq-optional/src/main/java/org/apache/activemq/filter/XMLBeansXPathEvaluator.java @@ -1,62 +1,62 @@ -/** - * - * 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.activemq.filter; - -import javax.jms.BytesMessage; -import javax.jms.JMSException; -import javax.jms.TextMessage; - -import org.apache.activemq.command.Message; -import org.apache.activemq.util.ByteArrayInputStream; -import org.apache.xmlbeans.XmlObject; - -public class XMLBeansXPathEvaluator implements XPathExpression.XPathEvaluator { - - private final String xpath; - - public XMLBeansXPathEvaluator(String xpath) { - this.xpath = xpath; - } - - public boolean evaluate(Message message) throws JMSException { - if( message instanceof TextMessage ) { - String text = ((TextMessage)message).getText(); - try { - XmlObject object = XmlObject.Factory.parse(text); - XmlObject[] objects = object.selectPath(xpath); - return object!=null && objects.length>0; - } catch (Throwable e) { - return false; - } - - } else if ( message instanceof BytesMessage ) { - BytesMessage bm = (BytesMessage) message; - byte data[] = new byte[(int) bm.getBodyLength()]; - bm.readBytes(data); - try { - XmlObject object = XmlObject.Factory.parse(new ByteArrayInputStream(data)); - XmlObject[] objects = object.selectPath(xpath); - return object!=null && objects.length>0; - } catch (Throwable e) { - return false; - } - } - return false; - } -} +/** + * + * 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.activemq.filter; + +import javax.jms.BytesMessage; +import javax.jms.JMSException; +import javax.jms.TextMessage; + +import org.apache.activemq.command.Message; +import org.apache.activemq.util.ByteArrayInputStream; +import org.apache.xmlbeans.XmlObject; + +public class XMLBeansXPathEvaluator implements XPathExpression.XPathEvaluator { + + private final String xpath; + + public XMLBeansXPathEvaluator(String xpath) { + this.xpath = xpath; + } + + public boolean evaluate(Message message) throws JMSException { + if( message instanceof TextMessage ) { + String text = ((TextMessage)message).getText(); + try { + XmlObject object = XmlObject.Factory.parse(text); + XmlObject[] objects = object.selectPath(xpath); + return object!=null && objects.length>0; + } catch (Throwable e) { + return false; + } + + } else if ( message instanceof BytesMessage ) { + BytesMessage bm = (BytesMessage) message; + byte data[] = new byte[(int) bm.getBodyLength()]; + bm.readBytes(data); + try { + XmlObject object = XmlObject.Factory.parse(new ByteArrayInputStream(data)); + XmlObject[] objects = object.selectPath(xpath); + return object!=null && objects.length>0; + } catch (Throwable e) { + return false; + } + } + return false; + } +}