You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2008/06/24 22:18:56 UTC

svn commit: r671330 [1/4] - in /servicemix/smx3/trunk/core: ./ servicemix-core/ servicemix-core/src/main/java/org/apache/servicemix/expression/ servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/ servicemix-core/src/main/java/org/apache/servi...

Author: gnodet
Date: Tue Jun 24 13:18:54 2008
New Revision: 671330

URL: http://svn.apache.org/viewvc?rev=671330&view=rev
Log:
Extract jaxp utils, mock and expressions in a new module

Added:
    servicemix/smx3/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jbi/
    servicemix/smx3/trunk/core/servicemix-utils/   (with props)
    servicemix/smx3/trunk/core/servicemix-utils/pom.xml
    servicemix/smx3/trunk/core/servicemix-utils/src/
    servicemix/smx3/trunk/core/servicemix-utils/src/main/
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/ConstantExpression.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/Expression.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/ExpressionEditor.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/ExpressionHelper.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JAXPBooleanXPathExpression.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JAXPNodeSetXPathExpression.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JAXPStringXPathExpression.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JAXPXPathExpression.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JAXPXPathXStreamExpression.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JaxenStringXPathExpression.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JaxenVariableContext.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JaxenXPathExpression.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/MessageVariableResolver.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/PropertyExpression.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/XMLBeansStringXPathExpression.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/XMLBeansXPathExpression.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/package.html
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/jbi/
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/jbi/jaxp/
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/jbi/jaxp/BytesSource.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/jbi/jaxp/DOMStreamReader.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/jbi/jaxp/DOMStreamWriter.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/jbi/jaxp/ExtendedNamespaceContext.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/jbi/jaxp/ExtendedXMLStreamReader.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/jbi/jaxp/FragmentStreamReader.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/jbi/jaxp/NamespaceContextImpl.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/jbi/jaxp/QNameHelper.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/jbi/jaxp/ResourceSource.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/jbi/jaxp/SimpleNamespaceContext.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/jbi/jaxp/SourceMarshaler.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/jbi/jaxp/SourceTransformer.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/jbi/jaxp/StAXSourceTransformer.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/jbi/jaxp/StaxSource.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/jbi/jaxp/StringSource.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/jbi/jaxp/W3CDOMStreamReader.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/jbi/jaxp/W3CDOMStreamWriter.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/jbi/jaxp/W3CNamespaceContext.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/jbi/jaxp/XMLStreamHelper.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/jbi/jaxp/package.html
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/tck/
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/tck/mock/
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/tck/mock/MockExchangeFactory.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/tck/mock/MockMessageExchange.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/tck/mock/MockNormalizedMessage.java
    servicemix/smx3/trunk/core/servicemix-utils/src/main/resources/
    servicemix/smx3/trunk/core/servicemix-utils/src/test/
    servicemix/smx3/trunk/core/servicemix-utils/src/test/java/
    servicemix/smx3/trunk/core/servicemix-utils/src/test/java/org/
    servicemix/smx3/trunk/core/servicemix-utils/src/test/java/org/apache/
    servicemix/smx3/trunk/core/servicemix-utils/src/test/java/org/apache/servicemix/
    servicemix/smx3/trunk/core/servicemix-utils/src/test/java/org/apache/servicemix/expression/
    servicemix/smx3/trunk/core/servicemix-utils/src/test/java/org/apache/servicemix/expression/ExpressionEditorTest.java
    servicemix/smx3/trunk/core/servicemix-utils/src/test/java/org/apache/servicemix/expression/ExpressionTestSupport.java
    servicemix/smx3/trunk/core/servicemix-utils/src/test/java/org/apache/servicemix/expression/JAXPXPathExpressionTest.java
    servicemix/smx3/trunk/core/servicemix-utils/src/test/java/org/apache/servicemix/expression/JAXPXPathXStreamExpressionTest.java
    servicemix/smx3/trunk/core/servicemix-utils/src/test/java/org/apache/servicemix/expression/XPathExpressionTest.java
    servicemix/smx3/trunk/core/servicemix-utils/src/test/java/org/apache/servicemix/jbi/
    servicemix/smx3/trunk/core/servicemix-utils/src/test/java/org/apache/servicemix/jbi/jaxp/
    servicemix/smx3/trunk/core/servicemix-utils/src/test/java/org/apache/servicemix/jbi/jaxp/AbstractStreamReaderTest.java
    servicemix/smx3/trunk/core/servicemix-utils/src/test/java/org/apache/servicemix/jbi/jaxp/FragmentStreamReaderTest.java
    servicemix/smx3/trunk/core/servicemix-utils/src/test/java/org/apache/servicemix/jbi/jaxp/SourceTransformerTest.java
    servicemix/smx3/trunk/core/servicemix-utils/src/test/java/org/apache/servicemix/jbi/jaxp/StaxSourceTest.java
    servicemix/smx3/trunk/core/servicemix-utils/src/test/java/org/apache/servicemix/jbi/jaxp/W3CDOMStreamReaderTest.java
    servicemix/smx3/trunk/core/servicemix-utils/src/test/resources/
    servicemix/smx3/trunk/core/servicemix-utils/src/test/resources/org/
    servicemix/smx3/trunk/core/servicemix-utils/src/test/resources/org/apache/
    servicemix/smx3/trunk/core/servicemix-utils/src/test/resources/org/apache/servicemix/
    servicemix/smx3/trunk/core/servicemix-utils/src/test/resources/org/apache/servicemix/expression/
    servicemix/smx3/trunk/core/servicemix-utils/src/test/resources/org/apache/servicemix/expression/expression-editor.xml
    servicemix/smx3/trunk/core/servicemix-utils/src/test/resources/org/apache/servicemix/jbi/
    servicemix/smx3/trunk/core/servicemix-utils/src/test/resources/org/apache/servicemix/jbi/jaxp/
    servicemix/smx3/trunk/core/servicemix-utils/src/test/resources/org/apache/servicemix/jbi/jaxp/test.xml
Removed:
    servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/expression/
    servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/
    servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/tck/mock/
    servicemix/smx3/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/expression/
    servicemix/smx3/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/jaxp/
    servicemix/smx3/trunk/core/servicemix-core/src/test/resources/org/apache/servicemix/expression/
    servicemix/smx3/trunk/core/servicemix-core/src/test/resources/org/apache/servicemix/jbi/jaxp/
Modified:
    servicemix/smx3/trunk/core/pom.xml
    servicemix/smx3/trunk/core/servicemix-core/pom.xml
    servicemix/smx3/trunk/core/servicemix-services/pom.xml

Modified: servicemix/smx3/trunk/core/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/pom.xml?rev=671330&r1=671329&r2=671330&view=diff
==============================================================================
--- servicemix/smx3/trunk/core/pom.xml (original)
+++ servicemix/smx3/trunk/core/pom.xml Tue Jun 24 13:18:54 2008
@@ -36,6 +36,7 @@
     <modules>
         <module>servicemix-jbi</module>
         <module>servicemix-services</module>
+        <module>servicemix-utils</module>
         <module>servicemix-core</module>
         <module>servicemix-audit</module>
     </modules>

Modified: servicemix/smx3/trunk/core/servicemix-core/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-core/pom.xml?rev=671330&r1=671329&r2=671330&view=diff
==============================================================================
--- servicemix/smx3/trunk/core/servicemix-core/pom.xml (original)
+++ servicemix/smx3/trunk/core/servicemix-core/pom.xml Tue Jun 24 13:18:54 2008
@@ -36,10 +36,14 @@
       <groupId>org.apache.servicemix</groupId>
       <artifactId>servicemix-jbi</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.apache.servicemix</groupId>
-      <artifactId>servicemix-services</artifactId>
-    </dependency>
+      <dependency>
+        <groupId>org.apache.servicemix</groupId>
+        <artifactId>servicemix-services</artifactId>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.servicemix</groupId>
+        <artifactId>servicemix-utils</artifactId>
+      </dependency>
     <dependency>
       <groupId>log4j</groupId>
       <artifactId>log4j</artifactId>
@@ -169,10 +173,6 @@
       <optional>true</optional>
     </dependency>
     <dependency>
-      <groupId>jaxen</groupId>
-      <artifactId>jaxen</artifactId>
-    </dependency>
-    <dependency>
       <groupId>commons-beanutils</groupId>
       <artifactId>commons-beanutils-core</artifactId>
     </dependency>
@@ -207,16 +207,6 @@
       <artifactId>junit</artifactId>
     </dependency>
     <dependency>
-      <groupId>xmlbeans</groupId>
-      <artifactId>xmlpublic</artifactId>
-      <optional>true</optional>
-    </dependency>
-    <dependency>
-      <groupId>xmlbeans</groupId>
-      <artifactId>xbean</artifactId>
-      <optional>true</optional>
-    </dependency>
-    <dependency>
       <groupId>org.logicblaze.lingo</groupId>
       <artifactId>lingo</artifactId>
       <scope>test</scope>

Modified: servicemix/smx3/trunk/core/servicemix-services/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-services/pom.xml?rev=671330&r1=671329&r2=671330&view=diff
==============================================================================
--- servicemix/smx3/trunk/core/servicemix-services/pom.xml (original)
+++ servicemix/smx3/trunk/core/servicemix-services/pom.xml Tue Jun 24 13:18:54 2008
@@ -43,6 +43,41 @@
       <artifactId>commons-logging</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.apache.servicemix</groupId>
+      <artifactId>servicemix-jbi</artifactId>
+    </dependency>
+      <dependency>
+        <groupId>jaxen</groupId>
+        <artifactId>jaxen</artifactId>
+          <optional>true</optional>
+      </dependency>
+      <dependency>
+        <groupId>xstream</groupId>
+        <artifactId>xstream</artifactId>
+          <optional>true</optional>
+      </dependency>
+      <dependency>
+        <groupId>xmlbeans</groupId>
+        <artifactId>xmlpublic</artifactId>
+        <optional>true</optional>
+      </dependency>
+      <dependency>
+        <groupId>xmlbeans</groupId>
+        <artifactId>xbean</artifactId>
+        <optional>true</optional>
+      </dependency>
+      <dependency>
+        <groupId>stax</groupId>
+        <artifactId>stax-api</artifactId>
+        <optional>true</optional>
+      </dependency>
+      <dependency>
+        <groupId>org.springframework</groupId>
+        <artifactId>spring-beans</artifactId>
+          <version>${spring-version}</version>
+        <optional>true</optional>
+      </dependency>
+    <dependency>
       <groupId>hsqldb</groupId>
       <artifactId>hsqldb</artifactId>
       <scope>test</scope>

Propchange: servicemix/smx3/trunk/core/servicemix-utils/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Jun 24 13:18:54 2008
@@ -0,0 +1,7 @@
+target
+*.iml
+*.ipr
+*.iws
+.classpath
+.project
+.settings

Added: servicemix/smx3/trunk/core/servicemix-utils/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-utils/pom.xml?rev=671330&view=auto
==============================================================================
--- servicemix/smx3/trunk/core/servicemix-utils/pom.xml (added)
+++ servicemix/smx3/trunk/core/servicemix-utils/pom.xml Tue Jun 24 13:18:54 2008
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+<!--
+
+    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.
+-->
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.servicemix</groupId>
+    <artifactId>core</artifactId>
+    <version>3.3-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>servicemix-utils</artifactId>
+  <packaging>jar</packaging>
+  <name>ServiceMix :: Utils</name>
+  <description>Various JBI related utilities</description>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-j2ee-connector_1.5_spec</artifactId>
+      <optional>true</optional>
+    </dependency>
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicemix</groupId>
+      <artifactId>servicemix-jbi</artifactId>
+    </dependency>
+      <dependency>
+        <groupId>jaxen</groupId>
+        <artifactId>jaxen</artifactId>
+          <optional>true</optional>
+      </dependency>
+      <dependency>
+        <groupId>xstream</groupId>
+        <artifactId>xstream</artifactId>
+          <optional>true</optional>
+      </dependency>
+      <dependency>
+        <groupId>xmlbeans</groupId>
+        <artifactId>xmlpublic</artifactId>
+        <optional>true</optional>
+      </dependency>
+      <dependency>
+        <groupId>xmlbeans</groupId>
+        <artifactId>xbean</artifactId>
+        <optional>true</optional>
+      </dependency>
+      <dependency>
+        <groupId>stax</groupId>
+        <artifactId>stax-api</artifactId>
+        <optional>true</optional>
+      </dependency>
+      <dependency>
+        <groupId>org.springframework</groupId>
+        <artifactId>spring-context</artifactId>
+          <version>${spring-version}</version>
+        <optional>true</optional>
+      </dependency>
+    <dependency>
+      <groupId>hsqldb</groupId>
+      <artifactId>hsqldb</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.derby</groupId>
+      <artifactId>derby</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jencks</groupId>
+      <artifactId>jencks</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>tranql</groupId>
+      <artifactId>tranql-connector</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.geronimo.modules</groupId>
+      <artifactId>geronimo-transaction</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.geronimo.modules</groupId>
+      <artifactId>geronimo-connector</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>hsqldb</groupId>
+      <artifactId>hsqldb</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-dao</artifactId>
+      <version>${spring-version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+      <dependency>
+        <groupId>xalan</groupId>
+        <artifactId>xalan</artifactId>
+          <scope>test</scope>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.xbean</groupId>
+        <artifactId>xbean-spring</artifactId>
+          <scope>test</scope>
+      </dependency>
+      <dependency>
+        <groupId>org.codehaus.woodstox</groupId>
+        <artifactId>wstx-asl</artifactId>
+          <scope>test</scope>
+      </dependency>
+  </dependencies>
+
+    <build>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.felix</groupId>
+          <artifactId>maven-bundle-plugin</artifactId>
+          <version>1.4.0</version>
+          <configuration>
+            <instructions>
+              <Bundle-Name>${project.name}</Bundle-Name>
+              <Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
+              <Export-Package>org.apache.servicemix*</Export-Package>
+              <Import-Package>
+                com.thoughtworks.xstream*;resolution:=optional,
+                javax.activation;resolution:=optional,
+                javax.resource.spi.work;resolution:=optional,
+                javax.security.auth;resolution:=optional,
+                javax.xml.stream*;resolution:=optional,
+                org.apache.xmlbeans*;resolution:=optional,
+                org.jaxen*;resolution:=optional,
+                org.springframework*;resolution:=optional,
+                *
+              </Import-Package>
+            </instructions>
+          </configuration>
+          <executions>
+            <execution>
+              <id>bundle-manifest</id>
+              <phase>process-classes</phase>
+              <goals>
+                <goal>manifest</goal>
+              </goals>
+            </execution>
+          </executions>
+        </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-jar-plugin</artifactId>
+          <version>2.1</version>
+          <configuration>
+            <archive>
+              <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
+            </archive>
+          </configuration>
+        </plugin>
+      </plugins>
+    </build>
+
+</project>

Added: servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/ConstantExpression.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/ConstantExpression.java?rev=671330&view=auto
==============================================================================
--- servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/ConstantExpression.java (added)
+++ servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/ConstantExpression.java Tue Jun 24 13:18:54 2008
@@ -0,0 +1,38 @@
+/*
+ * 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.servicemix.expression;
+
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+
+/**
+ * Represents a constant expression
+ * 
+ * @version $Revision: 426415 $
+ */
+public class ConstantExpression implements Expression {
+    private Object value;
+
+    public ConstantExpression(Object value) {
+        this.value = value;
+    }
+
+    public Object evaluate(MessageExchange exchange, NormalizedMessage message) throws MessagingException {
+        return value;
+    }
+}

Added: servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/Expression.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/Expression.java?rev=671330&view=auto
==============================================================================
--- servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/Expression.java (added)
+++ servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/Expression.java Tue Jun 24 13:18:54 2008
@@ -0,0 +1,38 @@
+/*
+ * 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.servicemix.expression;
+
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+ 
+/**
+ * An expression strategy for extracting or calculating some value from a message.
+ *
+ * @version $Revision: 564374 $
+ */
+public interface Expression {
+
+    /**
+     * Evaluates the expression on the given exchange and message.
+     *
+     * @param exchange the message exchange
+     * @param message the message, typically an inbound message
+     * @return the value of the expression
+     */
+    Object evaluate(MessageExchange exchange, NormalizedMessage message) throws MessagingException;
+}

Added: servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/ExpressionEditor.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/ExpressionEditor.java?rev=671330&view=auto
==============================================================================
--- servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/ExpressionEditor.java (added)
+++ servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/ExpressionEditor.java Tue Jun 24 13:18:54 2008
@@ -0,0 +1,28 @@
+/*
+ * 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.servicemix.expression;
+
+import java.beans.PropertyEditorSupport;
+
+public class ExpressionEditor extends PropertyEditorSupport {
+
+    @Override
+    public void setAsText(String text) throws IllegalArgumentException {
+        setValue(new ConstantExpression(text));
+    }
+
+}

Added: servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/ExpressionHelper.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/ExpressionHelper.java?rev=671330&view=auto
==============================================================================
--- servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/ExpressionHelper.java (added)
+++ servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/ExpressionHelper.java Tue Jun 24 13:18:54 2008
@@ -0,0 +1,53 @@
+/*
+ * 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.servicemix.expression;
+
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+
+/**
+ * A helper class for working with expressions.
+ * 
+ * @version $Revision: 564374 $
+ */
+public final class ExpressionHelper {
+    
+    private ExpressionHelper() {
+    }
+
+    /**
+     * Evaluates the given expression as a string value.
+     * 
+     * @param expression the expression to evaluate
+     * @param exchange the current exchange
+     * @param message the current message
+     * @param defaultValue the default value to use if the expression is null or the value of the expression is null
+     * @return the value of the expression as a string if it is not null or the defaultValue
+     * @throws MessagingException if the expression failed to be evaluated
+     */
+    public static String asString(Expression expression, MessageExchange exchange, 
+                                  NormalizedMessage message, String defaultValue) throws MessagingException {
+        if (expression != null) {
+            Object answer = expression.evaluate(exchange, message);
+            if (answer != null) {
+                return answer.toString();
+            }
+        }
+        return defaultValue;
+    }
+}

Added: servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JAXPBooleanXPathExpression.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JAXPBooleanXPathExpression.java?rev=671330&view=auto
==============================================================================
--- servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JAXPBooleanXPathExpression.java (added)
+++ servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JAXPBooleanXPathExpression.java Tue Jun 24 13:18:54 2008
@@ -0,0 +1,48 @@
+/*
+ * 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.servicemix.expression;
+
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+
+/**
+ * Evaluates an XPath expression and coerces the result into a String.
+ * 
+ * @org.apache.xbean.XBean element="xpathBoolean"
+ * 
+ * @version $Revision: 359151 $
+ */
+public class JAXPBooleanXPathExpression extends JAXPXPathExpression {
+
+    public JAXPBooleanXPathExpression() {
+    }
+
+    public JAXPBooleanXPathExpression(String xpath) throws Exception {
+        super(xpath);
+    }
+
+    public Object evaluateXPath(Object object) throws XPathExpressionException {
+        return getXPathExpression().evaluate(object, XPathConstants.BOOLEAN);
+    }
+
+    public Object evaluate(MessageExchange exchange, NormalizedMessage message) throws MessagingException {
+        return evaluate(exchange, message, XPathConstants.BOOLEAN);
+    }
+}

Added: servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JAXPNodeSetXPathExpression.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JAXPNodeSetXPathExpression.java?rev=671330&view=auto
==============================================================================
--- servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JAXPNodeSetXPathExpression.java (added)
+++ servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JAXPNodeSetXPathExpression.java Tue Jun 24 13:18:54 2008
@@ -0,0 +1,46 @@
+/*
+ * 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.servicemix.expression;
+
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+
+/**
+ * Evaluates an XPath expression and coerces the result into a String.
+ * 
+ * @version $Revision: 359151 $
+ */
+public class JAXPNodeSetXPathExpression extends JAXPXPathExpression {
+
+    public JAXPNodeSetXPathExpression() {
+    }
+
+    public JAXPNodeSetXPathExpression(String xpath) throws Exception {
+        super(xpath);
+    }
+
+    public Object evaluateXPath(Object object) throws XPathExpressionException {
+        return getXPathExpression().evaluate(object, XPathConstants.NODESET);
+    }
+
+    public Object evaluate(MessageExchange exchange, NormalizedMessage message) throws MessagingException {
+        return evaluate(exchange, message, XPathConstants.NODESET);
+    }
+}

Added: servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JAXPStringXPathExpression.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JAXPStringXPathExpression.java?rev=671330&view=auto
==============================================================================
--- servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JAXPStringXPathExpression.java (added)
+++ servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JAXPStringXPathExpression.java Tue Jun 24 13:18:54 2008
@@ -0,0 +1,48 @@
+/*
+ * 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.servicemix.expression;
+
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+
+/**
+ * Evaluates an XPath expression and coerces the result into a String.
+ * 
+ * @org.apache.xbean.XBean element="xpathString"
+ * 
+ * @version $Revision: 654786 $
+ */
+public class JAXPStringXPathExpression extends JAXPXPathExpression {
+
+    public JAXPStringXPathExpression() {
+    }
+
+    public JAXPStringXPathExpression(String xpath) {
+        super(xpath);
+    }
+
+    public Object evaluateXPath(Object object) throws XPathExpressionException {
+        return getXPathExpression().evaluate(object, XPathConstants.STRING);
+    }
+
+    public Object evaluate(MessageExchange exchange, NormalizedMessage message) throws MessagingException {
+        return evaluate(exchange, message, XPathConstants.STRING);
+    }
+}

Added: servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JAXPXPathExpression.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JAXPXPathExpression.java?rev=671330&view=auto
==============================================================================
--- servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JAXPXPathExpression.java (added)
+++ servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JAXPXPathExpression.java Tue Jun 24 13:18:54 2008
@@ -0,0 +1,275 @@
+/*
+ * 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.servicemix.expression;
+
+import java.io.IOException;
+
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+import javax.xml.xpath.XPathFunctionResolver;
+
+import org.xml.sax.SAXException;
+
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.springframework.beans.factory.InitializingBean;
+
+/**
+ * Evalutes an XPath expression on the given message using JAXP
+ * 
+ * @org.apache.xbean.XBean element="xpath"
+ * 
+ * @version $Revision: 654087 $
+ */
+public class JAXPXPathExpression implements Expression, InitializingBean {
+    
+    private String xpath;
+
+    private boolean useMessageContent = true;
+
+    private SourceTransformer transformer = new SourceTransformer();
+
+    private MessageVariableResolver variableResolver = new MessageVariableResolver();
+
+    private XPathExpression xPathExpression;
+
+    private XPathFunctionResolver functionResolver;
+
+    private NamespaceContext namespaceContext;
+
+    private XPathFactory factory;
+
+    public JAXPXPathExpression() {
+    }
+
+    /**
+     * A helper constructor to make a fully created expression.
+     */
+    public JAXPXPathExpression(String xpath) {
+        this.xpath = xpath;
+    }
+
+    /**
+     * Compiles the xpath expression.
+     */
+    public void afterPropertiesSet() throws XPathExpressionException {
+        if (xPathExpression == null) {
+            if (xpath == null) {
+                throw new IllegalArgumentException("You must specify the xpath property");
+            }
+
+            if (factory == null) {
+                factory = XPathFactory.newInstance();
+            }
+            XPath xpathObject = factory.newXPath();
+            xpathObject.setXPathVariableResolver(variableResolver);
+            if (functionResolver != null) {
+                xpathObject.setXPathFunctionResolver(functionResolver);
+            }
+            if (namespaceContext != null) {
+                xpathObject.setNamespaceContext(namespaceContext);
+            }
+            xPathExpression = xpathObject.compile(xpath);
+        }
+    }
+
+    /**
+     * Evaluates the XPath expression and returns the string values for the XML items described
+     * by that expression.
+     *
+     * Before evaluating the xpath expression, it will be compiled by calling
+     * the {@link #afterPropertiesSet()} method.
+     *
+     * @param exchange MessageExchange to use on MessageVariableResolver
+     * @param message  NormalizedMessage to use on MessageVariableResolver
+     *
+     * @return Object  Contains the string values for the XML items described by the provided XPath
+     *                 expression
+     */
+    public Object evaluate(MessageExchange exchange, NormalizedMessage message) throws MessagingException {
+        return evaluate(exchange, message, XPathConstants.STRING);
+    }
+
+    /**
+     * Evaluates the XPath expression and the XML items described by that expression. The type is
+     * determined by the returnType parameter.  
+     *
+     * Before evaluating the xpath expression, it will be compiled by calling
+     * the {@link #afterPropertiesSet()} method.
+     *
+     * @param exchange    MessageExchange to use on MessageVariableResolver
+     * @param message     NormalizedMessage to use on MessageVariableResolver
+     * @param returnType  QName as defined by javax.xml.xpath.XPathConstants that describes the
+     *                    desired type of the object to be retuned
+     *
+     * @return Object    Contains the XML items described by the provided XPath expression. The type is
+     *                   determined by the returnType parameter.
+     */
+    public Object evaluate(MessageExchange exchange, NormalizedMessage message, QName returnType) throws MessagingException {
+        try {
+            afterPropertiesSet();
+            Object object = getXMLNode(exchange, message);
+            synchronized (this) {
+                variableResolver.setExchange(exchange);
+                variableResolver.setMessage(message);
+                return evaluateXPath(object, returnType);
+            }
+        } catch (TransformerException e) {
+            throw new MessagingException(e);
+        } catch (XPathExpressionException e) {
+            throw new MessagingException(e);
+        } catch (ParserConfigurationException e) {
+            throw new MessagingException(e);
+        } catch (IOException e) {
+            throw new MessagingException(e);
+        } catch (SAXException e) {
+            throw new MessagingException(e);
+        }
+    }
+
+    // Properties
+    // -------------------------------------------------------------------------
+    public String getXPath() {
+        return xpath;
+    }
+
+    public void setXPath(String xp) {
+        this.xpath = xp;
+    }
+
+    public boolean isUseMessageContent() {
+        return useMessageContent;
+    }
+
+    /**
+     * Specifies whether or not the XPath expression uses the message content.
+     * 
+     * By default, this property is <code>true</code>, but you can set it to
+     * <code>false</code> to avoid that the message content is converted to
+     * {@link StringSource}
+     * 
+     * @param useMessageContent
+     *            specify <code>false</code> if this expression does not
+     *            access the message content
+     */
+    public void setUseMessageContent(boolean useMessageContent) {
+        this.useMessageContent = useMessageContent;
+    }
+
+    public SourceTransformer getTransformer() {
+        return transformer;
+    }
+
+    public void setTransformer(SourceTransformer transformer) {
+        this.transformer = transformer;
+    }
+
+    public MessageVariableResolver getVariableResolver() {
+        return variableResolver;
+    }
+
+    public void setVariableResolver(MessageVariableResolver variableResolver) {
+        this.variableResolver = variableResolver;
+    }
+
+    public XPathFactory getFactory() {
+        return factory;
+    }
+
+    public void setFactory(XPathFactory factory) {
+        this.factory = factory;
+    }
+
+    public XPathFunctionResolver getFunctionResolver() {
+        return functionResolver;
+    }
+
+    public void setFunctionResolver(XPathFunctionResolver functionResolver) {
+        this.functionResolver = functionResolver;
+    }
+
+    public NamespaceContext getNamespaceContext() {
+        return namespaceContext;
+    }
+
+    public void setNamespaceContext(NamespaceContext namespaceContext) {
+        this.namespaceContext = namespaceContext;
+    }
+
+    // Implementation methods
+    // -------------------------------------------------------------------------
+    protected Object evaluateXPath(Object object) throws XPathExpressionException {
+        return xPathExpression.evaluate(object);
+    }
+
+    protected Object evaluateXPath(Object object, QName returnType) throws XPathExpressionException {
+        return xPathExpression.evaluate(object, returnType);
+    }
+
+    protected XPathExpression getXPathExpression() {
+        return xPathExpression;
+    }
+
+    protected Object getXMLNode(MessageExchange exchange, NormalizedMessage message) throws TransformerException, MessagingException,
+                    ParserConfigurationException, IOException, SAXException {
+        // ensure re-readability of the content if the expression also needs to
+        // access the content
+        if (useMessageContent) {
+            enableContentRereadability(message);
+        }
+        return transformer.toDOMNode(message);
+    }
+
+    /**
+     * Convert the given {@link NormalizedMessage} instance's content to a re-readable {@link javax.xml.transform.Source} This allows the
+     * content to be read more than once (e.g. for XPath evaluation or auditing).
+     *
+     * @param message
+     *            the {@link NormalizedMessage} to convert the content for
+     * @throws MessagingException
+     */
+    public void enableContentRereadability(NormalizedMessage message) throws MessagingException {
+        if (message.getContent() instanceof StreamSource) {
+            try {
+                String content = transformer.contentToString(message);
+                if (content != null) {
+                    message.setContent(new StringSource(content));
+                }
+            } catch (TransformerException e) {
+                throw new MessagingException("Unable to convert message content into StringSource", e);
+            } catch (ParserConfigurationException e) {
+                throw new MessagingException("Unable to convert message content into StringSource", e);
+            } catch (IOException e) {
+                throw new MessagingException("Unable to convert message content into StringSource", e);
+            } catch (SAXException e) {
+                throw new MessagingException("Unable to convert message content into StringSource", e);
+            }
+        }
+    }
+
+}

Added: servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JAXPXPathXStreamExpression.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JAXPXPathXStreamExpression.java?rev=671330&view=auto
==============================================================================
--- servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JAXPXPathXStreamExpression.java (added)
+++ servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JAXPXPathXStreamExpression.java Tue Jun 24 13:18:54 2008
@@ -0,0 +1,91 @@
+/*
+ * 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.servicemix.expression;
+
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.xpath.XPathConstants;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import com.thoughtworks.xstream.XStream;
+import com.thoughtworks.xstream.io.HierarchicalStreamReader;
+import com.thoughtworks.xstream.io.xml.DomReader;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.impl.Log4JLogger;
+
+
+/**
+ *
+ * @author Andrew Skiba <sk...@gmail.com>
+ */
+public class JAXPXPathXStreamExpression extends JAXPXPathExpression {
+
+    protected Log logger = new Log4JLogger(JAXPXPathXStreamExpression.class.getName());
+    private XStream xStream;
+
+    public JAXPXPathXStreamExpression() {
+        super();
+    }
+
+    /**
+     * A helper constructor to make a fully created expression.
+     * @param xpath 
+     */
+    public JAXPXPathXStreamExpression(String xpath) {
+        super(xpath);
+    }
+
+
+    @Override
+    public Object evaluate(MessageExchange exchange, NormalizedMessage message) throws MessagingException {
+        Object node = super.evaluate(exchange, message, XPathConstants.NODE);
+        HierarchicalStreamReader streamReader;
+        if (node instanceof Document) {
+            streamReader = new DomReader((Document) node);
+        } else if (node instanceof Element) {
+            streamReader = new DomReader((Element) node);
+        } else {
+            throw new IllegalArgumentException("DOMResult contains neither Document nor Element: " + node.getClass().getName());
+        }
+        return getXStream().unmarshal(streamReader);
+    }
+
+    public XStream getXStream() {
+        if (xStream == null) {
+            xStream = createXStream();
+        }
+        return xStream;
+    }
+
+    public void setXStream(XStream xStream) {
+        this.xStream = xStream;
+    }
+
+    //FIXME: copied as-is from XStreamMarshaler
+    private XStream createXStream() {
+        XStream answer = new XStream();
+        try {
+            answer.alias("invoke", Class.forName("org.logicblaze.lingo.LingoInvocation"));
+        } catch (ClassNotFoundException e) {
+            // Ignore
+        }
+        return answer;
+    }
+}

Added: servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JaxenStringXPathExpression.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JaxenStringXPathExpression.java?rev=671330&view=auto
==============================================================================
--- servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JaxenStringXPathExpression.java (added)
+++ servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JaxenStringXPathExpression.java Tue Jun 24 13:18:54 2008
@@ -0,0 +1,39 @@
+/*
+ * 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.servicemix.expression;
+
+import org.jaxen.JaxenException;
+
+/**
+ * An {@link Expression} which evaluates an XPath expression using  <a href="http://jaxen.org/"/>Jaxen</a> and
+ * returns the String value.
+ *
+ * @version $Revision: 450003 $
+ */
+public class JaxenStringXPathExpression extends JaxenXPathExpression {
+
+    public JaxenStringXPathExpression() {
+    }
+    
+    public JaxenStringXPathExpression(String xpath) throws Exception {
+        super(xpath);
+    }
+
+    protected Object evaluateXPath(Object object) throws JaxenException {
+        return getXpathObject().stringValueOf(object);
+    }
+}

Added: servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JaxenVariableContext.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JaxenVariableContext.java?rev=671330&view=auto
==============================================================================
--- servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JaxenVariableContext.java (added)
+++ servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JaxenVariableContext.java Tue Jun 24 13:18:54 2008
@@ -0,0 +1,111 @@
+/*
+ * 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.servicemix.expression;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.NormalizedMessage;
+
+import org.jaxen.UnresolvableException;
+import org.jaxen.VariableContext;
+
+/**
+ * A variable resolver for XPath expressions which support properties on the messge, exchange as well
+ * as making system properties and environment properties available.
+ *
+ * @version $Revision: 564374 $
+ */
+public class JaxenVariableContext implements VariableContext {
+    public static final String MESSAGE_NAMESPACE = "http://servicemix.org/xml/variables/message";
+
+    public static final String EXCHANGE_NAMESPACE = "http://servicemix.org/xml/variables/exchange";
+
+    public static final String SYSTEM_PROPERTIES_NAMESPACE = "http://servicemix.org/xml/variables/system-properties";
+
+    public static final String ENVIRONMENT_VARIABLES_NAMESPACE = "http://servicemix.org/xml/variables/environment-variables";
+
+    private MessageExchange exchange;
+
+    private NormalizedMessage message;
+
+    private Map variables;
+
+    public MessageExchange getExchange() {
+        return exchange;
+    }
+
+    public void setExchange(MessageExchange exchange) {
+        this.exchange = exchange;
+    }
+
+    public NormalizedMessage getMessage() {
+        return message;
+    }
+
+    public void setMessage(NormalizedMessage message) {
+        this.message = message;
+    }
+
+    public Map getVariables() {
+        return variables;
+    }
+
+    /**
+     * Allows other variables to be added to the variable scope
+     *
+     * @param variables
+     */
+    public void setVariables(Map variables) {
+        this.variables = variables;
+    }
+
+    public Object getVariableValue(String uri, String prefix, String localPart) throws UnresolvableException {
+        Object answer = null;
+
+        if (uri == null || uri.length() == 0) {
+            answer = message.getProperty(localPart);
+            if (answer == null) {
+                answer = exchange.getProperty(localPart);
+            }
+        } else if (uri.equals(MESSAGE_NAMESPACE)) {
+            answer = message.getProperty(localPart);
+        } else if (uri.equals(EXCHANGE_NAMESPACE)) {
+            answer = message.getProperty(localPart);
+        } else if (uri.equals(SYSTEM_PROPERTIES_NAMESPACE)) {
+            answer = System.getProperty(localPart);
+        } else if (uri.equals(ENVIRONMENT_VARIABLES_NAMESPACE)) {
+            answer = System.getProperty(System.getProperty(localPart));
+        }
+        return answer;
+    }
+
+    /**
+     * Allows a variable to be specified
+     *
+     * @param localPart
+     * @param value
+     */
+    public void setVariableValue(String localPart, Object value) {
+        if (variables == null) {
+            variables = new HashMap();
+        }
+        variables.put(localPart, value);
+    }
+
+}

Added: servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JaxenXPathExpression.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JaxenXPathExpression.java?rev=671330&view=auto
==============================================================================
--- servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JaxenXPathExpression.java (added)
+++ servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/JaxenXPathExpression.java Tue Jun 24 13:18:54 2008
@@ -0,0 +1,279 @@
+/*
+ * 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.servicemix.expression;
+
+import java.io.IOException;
+
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.stream.StreamSource;
+
+import org.w3c.dom.Node;
+
+import org.xml.sax.SAXException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.jaxen.FunctionContext;
+import org.jaxen.JaxenException;
+import org.jaxen.NamespaceContext;
+import org.jaxen.XPath;
+import org.jaxen.dom.DOMXPath;
+import org.springframework.beans.factory.InitializingBean;
+
+/**
+ * Evalutes an XPath expression on the given message using <a
+ * href="http://jaxen.org/"/>Jaxen</a>
+ * 
+ * @version $Revision: 564900 $
+ */
+public class JaxenXPathExpression implements Expression, InitializingBean {
+    
+    private static final transient Log LOG = LogFactory.getLog(JaxenXPathExpression.class);
+
+    private String xpath;
+
+    private boolean useMessageContent = true;
+
+    private SourceTransformer transformer = new SourceTransformer();
+
+    private JaxenVariableContext variableContext = new JaxenVariableContext();
+
+    private XPath xpathObject;
+
+    private NamespaceContext namespaceContext;
+
+    private FunctionContext functionContext;
+
+    public JaxenXPathExpression() {
+    }
+
+    /**
+     * A helper constructor to make a fully created expression. This constructor
+     * will call the {@link #afterPropertiesSet()} method to ensure this POJO is
+     * properly constructed.
+     */
+    public JaxenXPathExpression(String xpath) throws Exception {
+        this.xpath = xpath;
+        init();
+    }
+
+    public void afterPropertiesSet() throws Exception {
+        init();
+    }
+
+    private void init() throws JaxenException {
+        if (xpathObject == null) {
+            if (xpath == null) {
+                throw new IllegalArgumentException("You must specify the xpath property");
+            }
+            xpathObject = createXPath(xpath);
+            xpathObject.setVariableContext(variableContext);
+            if (namespaceContext != null) {
+                xpathObject.setNamespaceContext(namespaceContext);
+            }
+            if (functionContext != null) {
+                xpathObject.setFunctionContext(functionContext);
+            }
+        }
+    }
+
+    public Object evaluate(MessageExchange exchange, NormalizedMessage message) throws MessagingException {
+        try {
+            Object object = getXMLNode(exchange, message);
+            if (object == null) {
+                return null;
+            }
+            synchronized (this) {
+                variableContext.setExchange(exchange);
+                variableContext.setMessage(message);
+                return evaluateXPath(object);
+            }
+        } catch (TransformerException e) {
+            throw new MessagingException(e);
+        } catch (JaxenException e) {
+            throw new MessagingException(e);
+        } catch (ParserConfigurationException e) {
+            throw new MessagingException(e);
+        } catch (IOException e) {
+            throw new MessagingException(e);
+        } catch (SAXException e) {
+            throw new MessagingException(e);
+        }
+    }
+
+    public boolean matches(MessageExchange exchange, NormalizedMessage message) throws MessagingException {
+        try {
+            Object object = getXMLNode(exchange, message);
+            if (object == null) {
+                return false;
+            }
+            synchronized (this) {
+                variableContext.setExchange(exchange);
+                variableContext.setMessage(message);
+                return evaluateXPathAsBoolean(object);
+            }
+        } catch (TransformerException e) {
+            throw new MessagingException(e);
+        } catch (JaxenException e) {
+            throw new MessagingException(e);
+        } catch (ParserConfigurationException e) {
+            throw new MessagingException(e);
+        } catch (IOException e) {
+            throw new MessagingException(e);
+        } catch (SAXException e) {
+            throw new MessagingException(e);
+        }
+    }
+
+    // Properties
+    // -------------------------------------------------------------------------
+    public XPath getXpathObject() {
+        return xpathObject;
+    }
+
+    public void setXpathObject(XPath xpathObject) {
+        this.xpathObject = xpathObject;
+    }
+
+    public String getXpath() {
+        return xpath;
+    }
+
+    public void setXpath(String xpath) {
+        this.xpath = xpath;
+    }
+
+    public boolean isUseMessageContent() {
+        return useMessageContent;
+    }
+
+    /**
+     * Specifies whether or not the XPath expression uses the message content.
+     * 
+     * By default, this property is <code>true</code>, but you can set it to
+     * <code>false</code> to avoid that the message content is converted to
+     * {@link StringSource}
+     * 
+     * @param useMessageContent
+     *            specify <code>false</code> if this expression does not
+     *            access the message content
+     */
+    public void setUseMessageContent(boolean useMessageContent) {
+        this.useMessageContent = useMessageContent;
+    }
+
+    public SourceTransformer getTransformer() {
+        return transformer;
+    }
+
+    public void setTransformer(SourceTransformer transformer) {
+        this.transformer = transformer;
+    }
+
+    public JaxenVariableContext getVariableContext() {
+        return variableContext;
+    }
+
+    public void setVariableContext(JaxenVariableContext variableContext) {
+        this.variableContext = variableContext;
+    }
+
+    public NamespaceContext getNamespaceContext() {
+        return namespaceContext;
+    }
+
+    public void setNamespaceContext(NamespaceContext namespaceContext) {
+        this.namespaceContext = namespaceContext;
+    }
+
+    public FunctionContext getFunctionContext() {
+        return functionContext;
+    }
+
+    public void setFunctionContext(FunctionContext functionContext) {
+        this.functionContext = functionContext;
+    }
+
+    // Implementation methods
+    // -------------------------------------------------------------------------
+    protected final XPath createXPath(String xp) throws JaxenException {
+        return new DOMXPath(xp);
+    }
+
+    protected Object evaluateXPath(Object object) throws JaxenException {
+        return xpathObject.evaluate(object);
+    }
+
+    protected boolean evaluateXPathAsBoolean(Object object) throws JaxenException {
+        return xpathObject.booleanValueOf(object);
+    }
+
+    protected Object getXMLNode(MessageExchange exchange, NormalizedMessage message) throws TransformerException, MessagingException,
+                    ParserConfigurationException, IOException, SAXException {
+        Node node = null;
+        // ensure re-readability of the content if the expression also needs to
+        // access the content
+        if (useMessageContent) {
+            enableContentRereadability(message);
+        }
+        if (message != null) {
+            node = transformer.toDOMNode(message);
+        } else {
+            LOG.warn("Null message for exchange: " + exchange);
+        }
+        if (node == null) {
+            // lets make an empty document to avoid Jaxen throwing a
+            // NullPointerException
+            node = transformer.createDocument();
+        }
+        return node;
+    }
+
+    /**
+     * Convert the given {@link NormalizedMessage} instance's content to a re-readable {@link javax.xml.transform.Source} This allows the
+     * content to be read more than once (e.g. for XPath evaluation or auditing).
+     *
+     * @param message
+     *            the {@link NormalizedMessage} to convert the content for
+     * @throws MessagingException
+     */
+    public void enableContentRereadability(NormalizedMessage message) throws MessagingException {
+        if (message.getContent() instanceof StreamSource) {
+            try {
+                String content = transformer.contentToString(message);
+                if (content != null) {
+                    message.setContent(new StringSource(content));
+                }
+            } catch (TransformerException e) {
+                throw new MessagingException("Unable to convert message content into StringSource", e);
+            } catch (ParserConfigurationException e) {
+                throw new MessagingException("Unable to convert message content into StringSource", e);
+            } catch (IOException e) {
+                throw new MessagingException("Unable to convert message content into StringSource", e);
+            } catch (SAXException e) {
+                throw new MessagingException("Unable to convert message content into StringSource", e);
+            }
+        }
+    }
+
+}

Added: servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/MessageVariableResolver.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/MessageVariableResolver.java?rev=671330&view=auto
==============================================================================
--- servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/MessageVariableResolver.java (added)
+++ servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/MessageVariableResolver.java Tue Jun 24 13:18:54 2008
@@ -0,0 +1,72 @@
+/*
+ * 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.servicemix.expression;
+
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.namespace.QName;
+import javax.xml.xpath.XPathVariableResolver;
+
+/**
+ * A variable resolver for XPath expressions which support properties on the messge, exchange as well
+ * as making system properties and environment properties available.
+ *
+ * @version $Revision: 564374 $
+ */
+public class MessageVariableResolver implements XPathVariableResolver {
+    public static final String SYSTEM_PROPERTIES_NAMESPACE = "http://servicemix.org/xml/variables/system-properties";
+    public static final String ENVIRONMENT_VARIABLES = "http://servicemix.org/xml/variables/environment-variables";
+
+    private MessageExchange exchange;
+    private NormalizedMessage message;
+
+    public MessageExchange getExchange() {
+        return exchange;
+    }
+
+    public void setExchange(MessageExchange exchange) {
+        this.exchange = exchange;
+    }
+
+    public NormalizedMessage getMessage() {
+        return message;
+    }
+
+    public void setMessage(NormalizedMessage message) {
+        this.message = message;
+    }
+
+    public Object resolveVariable(QName name) {
+        // should we use other namespaces maybe?
+        String uri = name.getNamespaceURI();
+        String localPart = name.getLocalPart();
+
+        Object answer = null;
+
+        if (uri == null || uri.length() == 0) {
+            answer = message.getProperty(localPart);
+            if (answer == null) {
+                answer = exchange.getProperty(localPart);
+            }
+        } else if (uri.equals(SYSTEM_PROPERTIES_NAMESPACE)) {
+            answer = System.getProperty(localPart);
+        } else if (uri.equals(ENVIRONMENT_VARIABLES)) {
+            answer = System.getProperty(System.getProperty(localPart));
+        }
+        return answer;
+    }
+}

Added: servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/PropertyExpression.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/PropertyExpression.java?rev=671330&view=auto
==============================================================================
--- servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/PropertyExpression.java (added)
+++ servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/PropertyExpression.java Tue Jun 24 13:18:54 2008
@@ -0,0 +1,82 @@
+/*
+ * 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.servicemix.expression;
+
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+
+/**
+ * A simple expression which returns the value of a property on the message.
+ *
+ * @version $Revision: 451186 $
+ */
+public class PropertyExpression implements Expression {
+    private String property;
+    private Object defaultValue;
+    
+    public PropertyExpression() {
+    }
+
+    public PropertyExpression(String property) {
+        this.property = property;
+    }
+
+    public PropertyExpression(String property, Object defaultValue) {
+        this.property = property;
+        this.defaultValue = defaultValue;
+    }
+
+    /**
+     * @return the defaultValue
+     */
+    public Object getDefaultValue() {
+        return defaultValue;
+    }
+
+    /**
+     * @param defaultValue the defaultValue to set
+     */
+    public void setDefaultValue(Object defaultValue) {
+        this.defaultValue = defaultValue;
+    }
+
+    /**
+     * @return the property
+     */
+    public String getProperty() {
+        return property;
+    }
+
+    /**
+     * @param property the property to set
+     */
+    public void setProperty(String property) {
+        this.property = property;
+    }
+
+    public Object evaluate(MessageExchange exchange, NormalizedMessage message) throws MessagingException {
+        Object answer = message.getProperty(property);
+        if (answer == null) {
+            answer = exchange.getProperty(property);
+            if (answer == null) {
+                answer = defaultValue;
+            }
+        }
+        return answer;
+    }
+}

Added: servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/XMLBeansStringXPathExpression.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/XMLBeansStringXPathExpression.java?rev=671330&view=auto
==============================================================================
--- servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/XMLBeansStringXPathExpression.java (added)
+++ servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/XMLBeansStringXPathExpression.java Tue Jun 24 13:18:54 2008
@@ -0,0 +1,54 @@
+/*
+ * 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.servicemix.expression;
+
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlOptions;
+
+/**
+ * An {@link Expression} which evaluates an XPath expression using <a href="http://xmlbeans.apache.org/">XMLBeans</a> and
+ * returns the String value.
+ *
+ * @version $Revision: 564374 $
+ */
+public class XMLBeansStringXPathExpression extends XMLBeansXPathExpression {
+    public XMLBeansStringXPathExpression(String xpath) {
+        super(xpath);
+    }
+
+    protected Object evaluateXPath(XmlObject object, String xpath, XmlOptions options) {
+        XmlObject[] xmlObjects = object.selectPath(xpath);
+        if (xmlObjects == null || xmlObjects.length == 0) {
+            return "";
+        } else if (xmlObjects.length == 1) {
+            return asString(xmlObjects[0]);
+        } else {
+            StringBuffer buffer = new StringBuffer();
+            for (int i = 0; i < xmlObjects.length; i++) {
+                XmlObject xmlObject = xmlObjects[i];
+                buffer.append(asString(xmlObject));
+            }
+            return buffer.toString();
+        }
+    }
+
+    protected String asString(XmlObject xmlObject) {
+        XmlCursor cursor = xmlObject.newCursor();
+        return cursor.getTextValue();
+    }
+}

Added: servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/XMLBeansXPathExpression.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/XMLBeansXPathExpression.java?rev=671330&view=auto
==============================================================================
--- servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/XMLBeansXPathExpression.java (added)
+++ servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/XMLBeansXPathExpression.java Tue Jun 24 13:18:54 2008
@@ -0,0 +1,69 @@
+/*
+ * 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.servicemix.expression;
+
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.sax.SAXResult;
+
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlOptions;
+import org.apache.xmlbeans.XmlSaxHandler;
+
+/**
+ * An {@link Expression} which evaluates an XPath expression using <a href="http://xmlbeans.apache.org/">XMLBeans</a>
+ *
+ * @version $Revision: 564374 $
+ */
+public class XMLBeansXPathExpression implements Expression {
+    
+    private String xpath;
+
+    private XmlOptions options = new XmlOptions();
+
+    private SourceTransformer transformer = new SourceTransformer();
+
+    public XMLBeansXPathExpression(String xp) {
+        this.xpath = xp;
+    }
+
+    public Object evaluate(MessageExchange exchange, NormalizedMessage message) throws MessagingException {
+        try {
+            XmlSaxHandler handler = XmlObject.Factory.newXmlSaxHandler();
+            SAXResult result = new SAXResult(handler.getContentHandler());
+            transformer.toResult(message.getContent(), result);
+            XmlObject object = handler.getObject();
+            return evaluateXPath(object, xpath, options);
+        } catch (TransformerException e) {
+            throw new MessagingException(e);
+        } catch (XmlException e) {
+            throw new MessagingException(e);
+        }
+    }
+
+    protected Object evaluateXPath(XmlObject object, String xp, XmlOptions opts) {
+        XmlObject[] xmlObjects = object.selectPath(xp, opts);
+        if (xmlObjects.length == 1) {
+            return xmlObjects[0];
+        }
+        return xmlObjects;
+    }
+}

Added: servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/package.html
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/package.html?rev=671330&view=auto
==============================================================================
--- servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/package.html (added)
+++ servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/expression/package.html Tue Jun 24 13:18:54 2008
@@ -0,0 +1,27 @@
+<!--
+
+    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.
+
+-->
+<html>
+<head>
+</head>
+<body>
+
+A pluggable expression library.
+
+</body>
+</html>

Added: servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/jbi/jaxp/BytesSource.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/jbi/jaxp/BytesSource.java?rev=671330&view=auto
==============================================================================
--- servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/jbi/jaxp/BytesSource.java (added)
+++ servicemix/smx3/trunk/core/servicemix-utils/src/main/java/org/apache/servicemix/jbi/jaxp/BytesSource.java Tue Jun 24 13:18:54 2008
@@ -0,0 +1,60 @@
+/*
+ * 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.servicemix.jbi.jaxp;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+
+import javax.xml.transform.stream.StreamSource;
+
+/**
+ * A helper class which provides a JAXP {@link javax.xml.transform.Source} from a byte[]
+ * which can be read as many times as required.
+ *
+ * @version $Revision: 564607 $
+ */
+public class BytesSource extends StreamSource {
+    private byte[] data;
+
+    public BytesSource(byte[] data) {
+        this.data = data;
+    }
+
+    public BytesSource(byte[] data, String systemId) {
+        this.data = data;
+        setSystemId(systemId);
+    }
+
+    public InputStream getInputStream() {
+        return new ByteArrayInputStream(data);
+    }
+
+    public Reader getReader() {
+        return new InputStreamReader(getInputStream());
+    }
+
+    public byte[] getData() {
+        return data;
+    }
+
+    public String toString() {
+        return "BytesSource[" + new String(data) + "]";
+    }
+
+}