You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2010/01/18 18:15:35 UTC

svn commit: r900466 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/builder/ main/java/org/apache/camel/component/mock/ main/java/org/apache/camel/converter/jaxp/ main/java/org/apache/camel/model/language/ test/java/org/apache/camel/builde...

Author: davsclaus
Date: Mon Jan 18 17:15:34 2010
New Revision: 900466

URL: http://svn.apache.org/viewvc?rev=900466&view=rev
Log:
CAMEL-2375: Refactored ExpressionClause to let it be reusable in builders outside the route definitions.

Added:
    camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java   (with props)
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/mock/MockAssertionClauseTest.java   (with props)
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionClause.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/builder/NotifyBuilder.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/converter/jaxp/XmlConverter.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/ExpressionDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/MethodCallExpression.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/NamespaceAwareExpression.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/TokenizerExpression.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/XPathExpression.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/XQueryExpression.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/builder/NotifyBuilderTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionClause.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionClause.java?rev=900466&r1=900465&r2=900466&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionClause.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionClause.java Mon Jan 18 17:15:34 2010
@@ -22,9 +22,6 @@
 import org.apache.camel.builder.xml.Namespaces;
 import org.apache.camel.model.ExpressionNode;
 import org.apache.camel.model.language.ExpressionDefinition;
-import org.apache.camel.model.language.MethodCallExpression;
-import org.apache.camel.model.language.XPathExpression;
-import org.apache.camel.model.language.XQueryExpression;
 
 /**
  * Represents an expression clause within the DSL which when the expression is
@@ -33,11 +30,10 @@
  * @version $Revision$
  */
 public class ExpressionClause<T> extends ExpressionDefinition {
-    private T result;
-    private String language;
+    private ExpressionClauseSupport<T> delegate;
 
     public ExpressionClause(T result) {
-        this.result = result;
+        this.delegate = new ExpressionClauseSupport<T>(result);
     }
 
     public static <T extends ExpressionNode> ExpressionClause<T> createAndSetExpression(T result) {
@@ -53,57 +49,56 @@
      * Specify an {@link Expression} instance
      */
     public T expression(Expression expression) {
-        setExpressionValue(expression);
-        return result;
+        return delegate.expression(expression);
     }
 
     /**
      * Specify the constant expression value
      */
     public T constant(Object value) {
-        return expression(ExpressionBuilder.constantExpression(value));
+        return delegate.constant(value);
     }
 
     /**
      * An expression of the exchange
      */
     public T exchange() {
-        return expression(ExpressionBuilder.exchangeExpression());
+        return delegate.exchange();
     }
 
     /**
      * An expression of an inbound message
      */
     public T inMessage() {
-        return expression(ExpressionBuilder.inMessageExpression());
+        return delegate.inMessage();
     }
 
     /**
      * An expression of an inbound message
      */
     public T outMessage() {
-        return expression(ExpressionBuilder.outMessageExpression());
+        return delegate.outMessage();
     }
 
     /**
      * An expression of an inbound message body
      */
     public T body() {
-        return expression(ExpressionBuilder.bodyExpression());
+        return delegate.body();
     }
 
     /**
      * An expression of an inbound message body converted to the expected type
      */
     public T body(Class<?> expectedType) {
-        return expression(ExpressionBuilder.bodyExpression(expectedType));
+        return delegate.body(expectedType);
     }
 
     /**
      * An expression of an outbound message body
      */
     public T outBody() {
-        return expression(ExpressionBuilder.outBodyExpression());
+        return delegate.outBody();
     }
 
     /**
@@ -111,49 +106,49 @@
      */
     @SuppressWarnings("unchecked")
     public T outBody(Class expectedType) {
-        return expression(ExpressionBuilder.outBodyExpression(expectedType));
+        return delegate.outBody(expectedType);
     }
 
     /**
      * An expression of an inbound message header of the given name
      */
     public T header(String name) {
-        return expression(ExpressionBuilder.headerExpression(name));
+        return delegate.header(name);
     }
 
     /**
      * An expression of the inbound headers
      */
     public T headers() {
-        return expression(ExpressionBuilder.headersExpression());
+        return delegate.headers();
     }
 
     /**
      * An expression of an outbound message header of the given name
      */
     public T outHeader(String name) {
-        return expression(ExpressionBuilder.outHeaderExpression(name));
+        return delegate.outHeader(name);
     }
 
     /**
      * An expression of the outbound headers
      */
     public T outHeaders() {
-        return expression(ExpressionBuilder.outHeadersExpression());
+        return delegate.outHeaders();
     }
 
     /**
      * An expression of an exchange property of the given name
      */
     public T property(String name) {
-        return expression(ExpressionBuilder.propertyExpression(name));
+        return delegate.property(name);
     }
 
     /**
      * An expression of the exchange properties
      */
     public T properties() {
-        return expression(ExpressionBuilder.propertiesExpression());
+        return delegate.properties();
     }
 
     // Languages
@@ -169,9 +164,7 @@
      * @return the builder to continue processing the DSL
      */
     public T method(String bean) {
-        MethodCallExpression expression = new MethodCallExpression(bean);
-        setExpressionType(expression);
-        return result;
+        return delegate.method(bean);
     }
     
     /**
@@ -184,9 +177,7 @@
      * @return the builder to continue processing the DSL
      */
     public T method(Object instance) {
-        MethodCallExpression expression = new MethodCallExpression(instance);
-        setExpressionType(expression);
-        return result;
+        return delegate.method(instance);
     }
 
     /**
@@ -199,9 +190,7 @@
      * @return the builder to continue processing the DSL
      */
     public T method(Class<?> beanType) {
-        MethodCallExpression expression = new MethodCallExpression(beanType);
-        setExpressionType(expression);
-        return result;
+        return delegate.method(beanType);
     }
 
     /**
@@ -215,9 +204,7 @@
      * @return the builder to continue processing the DSL
      */
     public T method(String bean, String method) {
-        MethodCallExpression expression = new MethodCallExpression(bean, method);
-        setExpressionType(expression);
-        return result;
+        return delegate.method(bean, method);
     }
     
     /**
@@ -231,9 +218,7 @@
      * @return the builder to continue processing the DSL
      */
     public T method(Object instance, String method) {
-        MethodCallExpression expression = new MethodCallExpression(instance, method);
-        setExpressionType(expression);
-        return result;
+        return delegate.method(instance, method);
     }
 
     /**
@@ -247,9 +232,7 @@
      * @return the builder to continue processing the DSL
      */
     public T method(Class<?> beanType, String method) {
-        MethodCallExpression expression = new MethodCallExpression(beanType, method);
-        setExpressionType(expression);
-        return result;
+        return delegate.method(beanType, method);
     }
 
     /**
@@ -261,7 +244,7 @@
      * @return the builder to continue processing the DSL
      */
     public T el(String text) {
-        return language("el", text);
+        return delegate.el(text);
     }
 
     /**
@@ -272,7 +255,7 @@
      * @return the builder to continue processing the DSL
      */
     public T groovy(String text) {
-        return language("groovy", text);
+        return delegate.groovy(text);
     }
 
     /**
@@ -284,7 +267,7 @@
      * @return the builder to continue processing the DSL
      */
     public T javaScript(String text) {
-        return language("js", text);
+        return delegate.javaScript(text);
     }
 
     /**
@@ -294,7 +277,7 @@
      * @return the builder to continue processing the DSL
      */
     public T jxpath(String text) {
-        return language("jxpath", text);
+        return delegate.jxpath(text);
     }
 
     /**
@@ -305,7 +288,7 @@
      * @return the builder to continue processing the DSL
      */
     public T ognl(String text) {
-        return language("ognl", text);
+        return delegate.ognl(text);
     }
 
     /**
@@ -316,7 +299,7 @@
      * @return the builder to continue processing the DSL
      */
     public T mvel(String text) {
-        return language("mvel", text);
+        return delegate.mvel(text);
     }
 
     /**
@@ -327,7 +310,7 @@
      * @return the builder to continue processing the DSL
      */
     public T php(String text) {
-        return language("php", text);
+        return delegate.php(text);
     }
 
     /**
@@ -338,7 +321,7 @@
      * @return the builder to continue processing the DSL
      */
     public T python(String text) {
-        return language("python", text);
+        return delegate.python(text);
     }
 
     /**
@@ -349,7 +332,7 @@
      * @return the builder to continue processing the DSL
      */
     public T ruby(String text) {
-        return language("ruby", text);
+        return delegate.ruby(text);
     }
 
     /**
@@ -360,7 +343,7 @@
      * @return the builder to continue processing the DSL
      */
     public T sql(String text) {
-        return language("sql", text);
+        return delegate.sql(text);
     }
 
     /**
@@ -371,7 +354,7 @@
      * @return the builder to continue processing the DSL
      */
     public T simple(String text) {
-        return language("simple", text);
+        return delegate.simple(text);
     }
 
     /**
@@ -382,7 +365,7 @@
      * @return the builder to continue processing the DSL
      */
     public T xpath(String text) {
-        return language("xpath", text);
+        return delegate.xpath(text);
     }
 
     /**
@@ -394,10 +377,7 @@
      * @return the builder to continue processing the DSL
      */
     public T xpath(String text, Class<?> resultType) {
-        XPathExpression expression = new XPathExpression(text);
-        expression.setResultType(resultType);
-        setExpressionType(expression);
-        return result;
+        return delegate.xpath(text, resultType);
     }
 
     /**
@@ -411,7 +391,7 @@
      * @return the builder to continue processing the DSL
      */
     public T xpath(String text, Class<?> resultType, Namespaces namespaces) {
-        return xpath(text, resultType, namespaces.getNamespaces());
+        return delegate.xpath(text, resultType, namespaces);
     }
 
     /**
@@ -425,11 +405,7 @@
      * @return the builder to continue processing the DSL
      */
     public T xpath(String text, Class<?> resultType, Map<String, String> namespaces) {
-        XPathExpression expression = new XPathExpression(text);
-        expression.setResultType(resultType);
-        expression.setNamespaces(namespaces);
-        setExpressionType(expression);
-        return result;
+        return delegate.xpath(text, resultType, namespaces);
     }
 
     /**
@@ -441,7 +417,7 @@
      * @return the builder to continue processing the DSL
      */
     public T xpath(String text, Namespaces namespaces) {
-        return xpath(text, namespaces.getNamespaces());
+        return delegate.xpath(text, namespaces);
     }
 
     /**
@@ -453,10 +429,7 @@
      * @return the builder to continue processing the DSL
      */
     public T xpath(String text, Map<String, String> namespaces) {
-        XPathExpression expression = new XPathExpression(text);
-        expression.setNamespaces(namespaces);
-        setExpressionType(expression);
-        return result;
+        return delegate.xpath(text, namespaces);
     }
 
     /**
@@ -467,7 +440,7 @@
      * @return the builder to continue processing the DSL
      */
     public T xquery(String text) {
-        return language("xquery", text);
+        return delegate.xquery(text);
     }
 
     /**
@@ -476,14 +449,11 @@
      * with the specified result type
      * 
      * @param text the expression to be evaluated
-     * @param resultType the return type expected by the expressiopn
+     * @param resultType the return type expected by the expression
      * @return the builder to continue processing the DSL
      */
     public T xquery(String text, Class<?> resultType) {
-        XQueryExpression expression = new XQueryExpression(text);
-        expression.setResultType(resultType);
-        setExpressionType(expression);
-        return result;
+        return delegate.xquery(text, resultType);
     }
 
     /**
@@ -497,7 +467,7 @@
      * @return the builder to continue processing the DSL
      */
     public T xquery(String text, Class<?> resultType, Namespaces namespaces) {
-        return xquery(text, resultType, namespaces.getNamespaces());
+        return delegate.xquery(text, resultType, namespaces);
     }
 
     /**
@@ -511,11 +481,7 @@
      * @return the builder to continue processing the DSL
      */
     public T xquery(String text, Class<?> resultType, Map<String, String> namespaces) {
-        XQueryExpression expression = new XQueryExpression(text);
-        expression.setResultType(resultType);
-        expression.setNamespaces(namespaces);
-        setExpressionType(expression);
-        return result;
+        return delegate.xquery(text, resultType, namespaces);
     }
 
     /**
@@ -528,7 +494,7 @@
      * @return the builder to continue processing the DSL
      */
     public T xquery(String text, Namespaces namespaces) {
-        return xquery(text, namespaces.getNamespaces());
+        return delegate.xquery(text, namespaces);
     }
 
     /**
@@ -541,10 +507,7 @@
      * @return the builder to continue processing the DSL
      */
     public T xquery(String text, Map<String, String> namespaces) {
-        XQueryExpression expression = new XQueryExpression(text);
-        expression.setNamespaces(namespaces);
-        setExpressionType(expression);
-        return result;
+        return delegate.xquery(text, namespaces);
     }
 
     /**
@@ -555,18 +518,45 @@
      * @return the builder to continue processing the DSL
      */
     public T language(String language, String expression) {
-        setLanguage(language);
-        setExpression(expression);
-        return result;
+        return delegate.language(language, expression);
     }
 
     // Properties
     // -------------------------------------------------------------------------
+
+
+    @Override
     public String getLanguage() {
-        return language;
+        return delegate.getLanguage();
+    }
+
+    @Override
+    public String getExpression() {
+        return delegate.getExpression();
+    }
+
+    @Override
+    public void setExpression(String expression) {
+        delegate.setExpression(expression);
+    }
+
+    @Override
+    public Expression getExpressionValue() {
+        return delegate.getExpressionValue();
+    }
+
+    @Override
+    protected void setExpressionValue(Expression expressionValue) {
+        delegate.setExpressionValue(expressionValue);
+    }
+
+    @Override
+    public ExpressionDefinition getExpressionType() {
+        return delegate.getExpressionType();
     }
 
-    public void setLanguage(String language) {
-        this.language = language;
+    @Override
+    protected void setExpressionType(ExpressionDefinition expressionType) {
+        delegate.setExpressionType(expressionType);
     }
 }

Added: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java?rev=900466&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java (added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java Mon Jan 18 17:15:34 2010
@@ -0,0 +1,611 @@
+/**
+ * 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.camel.builder;
+
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Expression;
+import org.apache.camel.builder.xml.Namespaces;
+import org.apache.camel.model.language.ExpressionDefinition;
+import org.apache.camel.model.language.MethodCallExpression;
+import org.apache.camel.model.language.XPathExpression;
+import org.apache.camel.model.language.XQueryExpression;
+import org.apache.camel.spi.Language;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * @version $Revision$
+ */
+public class ExpressionClauseSupport<T> {
+
+    private T result;
+    private String language;
+    private String expression;
+    private Expression expressionValue;
+    private ExpressionDefinition expressionType;
+
+    public ExpressionClauseSupport(T result) {
+        this.result = result;
+    }
+
+    // Helper expressions
+    // -------------------------------------------------------------------------
+
+    /**
+     * Specify an {@link org.apache.camel.Expression} instance
+     */
+    public T expression(Expression expression) {
+        setExpressionValue(expression);
+        return result;
+    }
+
+    /**
+     * Specify the constant expression value
+     */
+    public T constant(Object value) {
+        return expression(ExpressionBuilder.constantExpression(value));
+    }
+
+    /**
+     * An expression of the exchange
+     */
+    public T exchange() {
+        return expression(ExpressionBuilder.exchangeExpression());
+    }
+
+    /**
+     * An expression of an inbound message
+     */
+    public T inMessage() {
+        return expression(ExpressionBuilder.inMessageExpression());
+    }
+
+    /**
+     * An expression of an inbound message
+     */
+    public T outMessage() {
+        return expression(ExpressionBuilder.outMessageExpression());
+    }
+
+    /**
+     * An expression of an inbound message body
+     */
+    public T body() {
+        return expression(ExpressionBuilder.bodyExpression());
+    }
+
+    /**
+     * An expression of an inbound message body converted to the expected type
+     */
+    public T body(Class<?> expectedType) {
+        return expression(ExpressionBuilder.bodyExpression(expectedType));
+    }
+
+    /**
+     * An expression of an outbound message body
+     */
+    public T outBody() {
+        return expression(ExpressionBuilder.outBodyExpression());
+    }
+
+    /**
+     * An expression of an outbound message body converted to the expected type
+     */
+    @SuppressWarnings("unchecked")
+    public T outBody(Class expectedType) {
+        return expression(ExpressionBuilder.outBodyExpression(expectedType));
+    }
+
+    /**
+     * An expression of an inbound message header of the given name
+     */
+    public T header(String name) {
+        return expression(ExpressionBuilder.headerExpression(name));
+    }
+
+    /**
+     * An expression of the inbound headers
+     */
+    public T headers() {
+        return expression(ExpressionBuilder.headersExpression());
+    }
+
+    /**
+     * An expression of an outbound message header of the given name
+     */
+    public T outHeader(String name) {
+        return expression(ExpressionBuilder.outHeaderExpression(name));
+    }
+
+    /**
+     * An expression of the outbound headers
+     */
+    public T outHeaders() {
+        return expression(ExpressionBuilder.outHeadersExpression());
+    }
+
+    /**
+     * An expression of an exchange property of the given name
+     */
+    public T property(String name) {
+        return expression(ExpressionBuilder.propertyExpression(name));
+    }
+
+    /**
+     * An expression of the exchange properties
+     */
+    public T properties() {
+        return expression(ExpressionBuilder.propertiesExpression());
+    }
+
+    // Languages
+    // -------------------------------------------------------------------------
+
+    /**
+     * Evaluates an expression using the <a
+     * href="http://camel.apache.org/bean-language.html>bean language</a>
+     * which basically means the bean is invoked to determine the expression
+     * value.
+     *
+     * @param bean the name of the bean looked up the registry
+     * @return the builder to continue processing the DSL
+     */
+    public T method(String bean) {
+        MethodCallExpression expression = new MethodCallExpression(bean);
+        setExpressionType(expression);
+        return result;
+    }
+
+    /**
+     * Evaluates an expression using the <a
+     * href="http://camel.apache.org/bean-language.html>bean language</a>
+     * which basically means the bean is invoked to determine the expression
+     * value.
+     *
+     * @param instance the instance of the bean
+     * @return the builder to continue processing the DSL
+     */
+    public T method(Object instance) {
+        MethodCallExpression expression = new MethodCallExpression(instance);
+        setExpressionType(expression);
+        return result;
+    }
+
+    /**
+     * Evaluates an expression using the <a
+     * href="http://camel.apache.org/bean-language.html>bean language</a>
+     * which basically means the bean is invoked to determine the expression
+     * value.
+     *
+     * @param beanType the Class of the bean which we want to invoke
+     * @return the builder to continue processing the DSL
+     */
+    public T method(Class<?> beanType) {
+        MethodCallExpression expression = new MethodCallExpression(beanType);
+        setExpressionType(expression);
+        return result;
+    }
+
+    /**
+     * Evaluates an expression using the <a
+     * href="http://camel.apache.org/bean-language.html>bean language</a>
+     * which basically means the bean is invoked to determine the expression
+     * value.
+     *
+     * @param bean the name of the bean looked up the registry
+     * @param method the name of the method to invoke on the bean
+     * @return the builder to continue processing the DSL
+     */
+    public T method(String bean, String method) {
+        MethodCallExpression expression = new MethodCallExpression(bean, method);
+        setExpressionType(expression);
+        return result;
+    }
+
+    /**
+     * Evaluates an expression using the <a
+     * href="http://camel.apache.org/bean-language.html>bean language</a>
+     * which basically means the bean is invoked to determine the expression
+     * value.
+     *
+     * @param instance the instance of the bean
+     * @param method the name of the method to invoke on the bean
+     * @return the builder to continue processing the DSL
+     */
+    public T method(Object instance, String method) {
+        MethodCallExpression expression = new MethodCallExpression(instance, method);
+        setExpressionType(expression);
+        return result;
+    }
+
+    /**
+     * Evaluates an expression using the <a
+     * href="http://camel.apache.org/bean-language.html>bean language</a>
+     * which basically means the bean is invoked to determine the expression
+     * value.
+     *
+     * @param beanType the Class of the bean which we want to invoke
+     * @param method the name of the method to invoke on the bean
+     * @return the builder to continue processing the DSL
+     */
+    public T method(Class<?> beanType, String method) {
+        MethodCallExpression expression = new MethodCallExpression(beanType, method);
+        setExpressionType(expression);
+        return result;
+    }
+
+    /**
+     * Evaluates the <a href="http://camel.apache.org/el.html">EL
+     * Language from JSP and JSF</a> using the <a
+     * href="http://camel.apache.org/juel.html">JUEL library</a>
+     *
+     * @param text the expression to be evaluated
+     * @return the builder to continue processing the DSL
+     */
+    public T el(String text) {
+        return language("el", text);
+    }
+
+    /**
+     * Evaluates a <a href="http://camel.apache.org/groovy.html">Groovy
+     * expression</a>
+     *
+     * @param text the expression to be evaluated
+     * @return the builder to continue processing the DSL
+     */
+    public T groovy(String text) {
+        return language("groovy", text);
+    }
+
+    /**
+     * Evaluates a <a
+     * href="http://camel.apache.org/java-script.html">JavaScript
+     * expression</a>
+     *
+     * @param text the expression to be evaluated
+     * @return the builder to continue processing the DSL
+     */
+    public T javaScript(String text) {
+        return language("js", text);
+    }
+
+    /**
+     * Evaluates a <a href="http://commons.apache.org/jxpath/">JXPath expression</a>
+     *
+     * @param text the expression to be evaluated
+     * @return the builder to continue processing the DSL
+     */
+    public T jxpath(String text) {
+        return language("jxpath", text);
+    }
+
+    /**
+     * Evaluates an <a href="http://camel.apache.org/ognl.html">OGNL
+     * expression</a>
+     *
+     * @param text the expression to be evaluated
+     * @return the builder to continue processing the DSL
+     */
+    public T ognl(String text) {
+        return language("ognl", text);
+    }
+
+    /**
+     * Evaluates a <a href="http://camel.apache.org/mvel.html">MVEL
+     * expression</a>
+     *
+     * @param text the expression to be evaluated
+     * @return the builder to continue processing the DSL
+     */
+    public T mvel(String text) {
+        return language("mvel", text);
+    }
+
+    /**
+     * Evaluates a <a href="http://camel.apache.org/php.html">PHP
+     * expression</a>
+     *
+     * @param text the expression to be evaluated
+     * @return the builder to continue processing the DSL
+     */
+    public T php(String text) {
+        return language("php", text);
+    }
+
+    /**
+     * Evaluates a <a href="http://camel.apache.org/python.html">Python
+     * expression</a>
+     *
+     * @param text the expression to be evaluated
+     * @return the builder to continue processing the DSL
+     */
+    public T python(String text) {
+        return language("python", text);
+    }
+
+    /**
+     * Evaluates a <a href="http://camel.apache.org/ruby.html">Ruby
+     * expression</a>
+     *
+     * @param text the expression to be evaluated
+     * @return the builder to continue processing the DSL
+     */
+    public T ruby(String text) {
+        return language("ruby", text);
+    }
+
+    /**
+     * Evaluates an <a href="http://camel.apache.org/sql.html">SQL
+     * expression</a>
+     *
+     * @param text the expression to be evaluated
+     * @return the builder to continue processing the DSL
+     */
+    public T sql(String text) {
+        return language("sql", text);
+    }
+
+    /**
+     * Evaluates a <a href="http://camel.apache.org/simple.html">Simple
+     * expression</a>
+     *
+     * @param text the expression to be evaluated
+     * @return the builder to continue processing the DSL
+     */
+    public T simple(String text) {
+        return language("simple", text);
+    }
+
+    /**
+     * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
+     * expression</a>
+     *
+     * @param text the expression to be evaluated
+     * @return the builder to continue processing the DSL
+     */
+    public T xpath(String text) {
+        return language("xpath", text);
+    }
+
+    /**
+     * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
+     * expression</a> with the specified result type
+     *
+     * @param text the expression to be evaluated
+     * @param resultType the return type expected by the expression
+     * @return the builder to continue processing the DSL
+     */
+    public T xpath(String text, Class<?> resultType) {
+        XPathExpression expression = new XPathExpression(text);
+        expression.setResultType(resultType);
+        setExpressionType(expression);
+        return result;
+    }
+
+    /**
+     * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
+     * expression</a> with the specified result type and set of namespace
+     * prefixes and URIs
+     *
+     * @param text the expression to be evaluated
+     * @param resultType the return type expected by the expression
+     * @param namespaces the namespace prefix and URIs to use
+     * @return the builder to continue processing the DSL
+     */
+    public T xpath(String text, Class<?> resultType, Namespaces namespaces) {
+        return xpath(text, resultType, namespaces.getNamespaces());
+    }
+
+    /**
+     * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
+     * expression</a> with the specified result type and set of namespace
+     * prefixes and URIs
+     *
+     * @param text the expression to be evaluated
+     * @param resultType the return type expected by the expression
+     * @param namespaces the namespace prefix and URIs to use
+     * @return the builder to continue processing the DSL
+     */
+    public T xpath(String text, Class<?> resultType, Map<String, String> namespaces) {
+        XPathExpression expression = new XPathExpression(text);
+        expression.setResultType(resultType);
+        expression.setNamespaces(namespaces);
+        setExpressionType(expression);
+        return result;
+    }
+
+    /**
+     * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
+     * expression</a> with the specified set of namespace prefixes and URIs
+     *
+     * @param text the expression to be evaluated
+     * @param namespaces the namespace prefix and URIs to use
+     * @return the builder to continue processing the DSL
+     */
+    public T xpath(String text, Namespaces namespaces) {
+        return xpath(text, namespaces.getNamespaces());
+    }
+
+    /**
+     * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
+     * expression</a> with the specified set of namespace prefixes and URIs
+     *
+     * @param text the expression to be evaluated
+     * @param namespaces the namespace prefix and URIs to use
+     * @return the builder to continue processing the DSL
+     */
+    public T xpath(String text, Map<String, String> namespaces) {
+        XPathExpression expression = new XPathExpression(text);
+        expression.setNamespaces(namespaces);
+        setExpressionType(expression);
+        return result;
+    }
+
+    /**
+     * Evaluates an <a
+     * href="http://camel.apache.org/xquery.html">XQuery expression</a>
+     *
+     * @param text the expression to be evaluated
+     * @return the builder to continue processing the DSL
+     */
+    public T xquery(String text) {
+        return language("xquery", text);
+    }
+
+    /**
+     * Evaluates an <a
+     * href="http://camel.apache.org/xquery.html">XQuery expression</a>
+     * with the specified result type
+     *
+     * @param text the expression to be evaluated
+     * @param resultType the return type expected by the expressiopn
+     * @return the builder to continue processing the DSL
+     */
+    public T xquery(String text, Class<?> resultType) {
+        XQueryExpression expression = new XQueryExpression(text);
+        expression.setResultType(resultType);
+        setExpressionType(expression);
+        return result;
+    }
+
+    /**
+     * Evaluates an <a
+     * href="http://camel.apache.org/xquery.html">XQuery expression</a>
+     * with the specified result type and set of namespace prefixes and URIs
+     *
+     * @param text the expression to be evaluated
+     * @param resultType the return type expected by the expression
+     * @param namespaces the namespace prefix and URIs to use
+     * @return the builder to continue processing the DSL
+     */
+    public T xquery(String text, Class<?> resultType, Namespaces namespaces) {
+        return xquery(text, resultType, namespaces.getNamespaces());
+    }
+
+    /**
+     * Evaluates an <a
+     * href="http://camel.apache.org/xquery.html">XQuery expression</a>
+     * with the specified result type and set of namespace prefixes and URIs
+     *
+     * @param text the expression to be evaluated
+     * @param resultType the return type expected by the expression
+     * @param namespaces the namespace prefix and URIs to use
+     * @return the builder to continue processing the DSL
+     */
+    public T xquery(String text, Class<?> resultType, Map<String, String> namespaces) {
+        XQueryExpression expression = new XQueryExpression(text);
+        expression.setResultType(resultType);
+        expression.setNamespaces(namespaces);
+        setExpressionType(expression);
+        return result;
+    }
+
+    /**
+     * Evaluates an <a
+     * href="http://camel.apache.org/xquery.html">XQuery expression</a>
+     * with the specified set of namespace prefixes and URIs
+     *
+     * @param text the expression to be evaluated
+     * @param namespaces the namespace prefix and URIs to use
+     * @return the builder to continue processing the DSL
+     */
+    public T xquery(String text, Namespaces namespaces) {
+        return xquery(text, namespaces.getNamespaces());
+    }
+
+    /**
+     * Evaluates an <a
+     * href="http://camel.apache.org/xquery.html">XQuery expression</a>
+     * with the specified set of namespace prefixes and URIs
+     *
+     * @param text the expression to be evaluated
+     * @param namespaces the namespace prefix and URIs to use
+     * @return the builder to continue processing the DSL
+     */
+    public T xquery(String text, Map<String, String> namespaces) {
+        XQueryExpression expression = new XQueryExpression(text);
+        expression.setNamespaces(namespaces);
+        setExpressionType(expression);
+        return result;
+    }
+
+    /**
+     * Evaluates a given language name with the expression text
+     *
+     * @param language the name of the language
+     * @param expression the expression in the given language
+     * @return the builder to continue processing the DSL
+     */
+    public T language(String language, String expression) {
+        setLanguage(language);
+        setExpression(expression);
+        return result;
+    }
+
+    // Properties
+    // -------------------------------------------------------------------------
+    public String getLanguage() {
+        return language;
+    }
+
+    public void setLanguage(String language) {
+        this.language = language;
+    }
+
+    public String getExpression() {
+        return expression;
+    }
+
+    public void setExpression(String expression) {
+        this.expression = expression;
+    }
+
+    public Expression getExpressionValue() {
+        return expressionValue;
+    }
+
+    public void setExpressionValue(Expression expressionValue) {
+        this.expressionValue = expressionValue;
+    }
+
+    public ExpressionDefinition getExpressionType() {
+        return expressionType;
+    }
+
+    public void setExpressionType(ExpressionDefinition expressionType) {
+        this.expressionType = expressionType;
+    }
+
+    protected Expression createExpression(CamelContext camelContext) {
+        if (getExpressionValue() == null) {
+            if (getExpressionType() != null) {
+                setExpressionValue(getExpressionType().createExpression(camelContext));
+            } else if (getExpression() != null) {
+                ObjectHelper.notNull("language", getLanguage());
+                Language language = camelContext.resolveLanguage(getLanguage());
+                setExpressionValue(language.createExpression(getExpression()));
+                configureExpression(camelContext, getExpressionValue());
+            }
+        }
+        return getExpressionValue();
+    }
+
+    protected void configureExpression(CamelContext camelContext, Expression expression) {
+    }
+
+}

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/NotifyBuilder.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/NotifyBuilder.java?rev=900466&r1=900465&r2=900466&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/NotifyBuilder.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/NotifyBuilder.java Mon Jan 18 17:15:34 2010
@@ -27,6 +27,7 @@
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
+import org.apache.camel.Expression;
 import org.apache.camel.Predicate;
 import org.apache.camel.Producer;
 import org.apache.camel.component.mock.MockEndpoint;
@@ -138,6 +139,34 @@
     }
 
     /**
+     * Optionally a filter to only allow matching {@link Exchange} to be used for matching.
+     *
+     * @return the builder
+     */
+    public ExpressionClauseSupport<NotifyBuilder> filter() {
+        final ExpressionClauseSupport<NotifyBuilder> clause = new ExpressionClauseSupport<NotifyBuilder>(this);
+        stack.push(new EventPredicateSupport() {
+
+            @Override
+            public boolean onExchange(Exchange exchange) {
+                // filter non matching exchanges
+                Expression exp = clause.createExpression(exchange.getContext());
+                return exp.evaluate(exchange, Boolean.class);
+            }
+
+            public boolean matches() {
+                return true;
+            }
+
+            @Override
+            public String toString() {
+                return "filter(" + clause + ")";
+            }
+        });
+        return clause;
+    }
+
+    /**
      * Sets a condition when <tt>number</tt> of {@link Exchange} has been received.
      * <p/>
      * The number matching is <i>at least</i> based which means that if more messages received

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java?rev=900466&r1=900465&r2=900466&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java Mon Jan 18 17:15:34 2010
@@ -23,19 +23,29 @@
 import org.apache.camel.Expression;
 import org.apache.camel.Predicate;
 import org.apache.camel.builder.ExpressionClause;
+import org.apache.camel.builder.ExpressionClauseSupport;
 import org.apache.camel.builder.ValueBuilder;
 import org.apache.camel.util.PredicateAssertHelper;
-import static org.apache.camel.builder.ExpressionBuilder.*;
+
+import static org.apache.camel.builder.ExpressionBuilder.bodyExpression;
+import static org.apache.camel.builder.ExpressionBuilder.headerExpression;
+import static org.apache.camel.builder.ExpressionBuilder.outBodyExpression;
+import static org.apache.camel.builder.ExpressionBuilder.propertyExpression;
 
 /**
  * A builder of assertions on message exchanges
  *
  * @version $Revision$
  */
-public abstract class AssertionClause implements Runnable {
+public abstract class AssertionClause<T> extends ExpressionClauseSupport implements Runnable {
 
     private List<Predicate> predicates = new ArrayList<Predicate>();
 
+    @SuppressWarnings("unchecked")
+    public AssertionClause(Object result) {
+        super(result);
+    }
+
     // Builder methods
     // -------------------------------------------------------------------------
 
@@ -117,7 +127,6 @@
         predicates.add(predicate);
     }
 
-
     /**
      * Public class needed for fluent builders
      */

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java?rev=900466&r1=900465&r2=900466&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java Mon Jan 18 17:15:34 2010
@@ -652,8 +652,8 @@
      * @param messageIndex the number of the message
      * @return the assertion clause
      */
-    public AssertionClause message(final int messageIndex) {
-        AssertionClause clause = new AssertionClause() {
+    public AssertionClause<MockEndpoint> message(final int messageIndex) {
+        final AssertionClause<MockEndpoint> clause = new AssertionClause<MockEndpoint>(this) {
             public void run() {
                 applyAssertionOn(MockEndpoint.this, messageIndex, assertExchangeReceived(messageIndex));
             }
@@ -667,8 +667,8 @@
      *
      * @return the assertion clause
      */
-    public AssertionClause allMessages() {
-        AssertionClause clause = new AssertionClause() {
+    public AssertionClause<MockEndpoint> allMessages() {
+        final AssertionClause<MockEndpoint> clause = new AssertionClause<MockEndpoint>(this) {
             public void run() {
                 List<Exchange> list = getReceivedExchanges();
                 int index = 0;

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/converter/jaxp/XmlConverter.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/jaxp/XmlConverter.java?rev=900466&r1=900465&r2=900466&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/converter/jaxp/XmlConverter.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/converter/jaxp/XmlConverter.java Mon Jan 18 17:15:34 2010
@@ -47,6 +47,7 @@
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 import org.xml.sax.XMLReader;
@@ -128,6 +129,14 @@
     }
 
     /**
+     * Converts the given NodeList to a boolean
+     */
+    @Converter
+    public Boolean toBoolean(NodeList list) {
+        return list.getLength() > 0;
+    }
+
+    /**
      * Converts the given byte[] to a Source
      */
     @Converter

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/ExpressionDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/ExpressionDefinition.java?rev=900466&r1=900465&r2=900466&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/ExpressionDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/ExpressionDefinition.java Mon Jan 18 17:15:34 2010
@@ -113,8 +113,7 @@
 
     public <T> T evaluate(Exchange exchange, Class<T> type) {
         if (expressionValue == null) {
-            RouteContext routeContext = new DefaultRouteContext(exchange.getContext());
-            expressionValue = createExpression(routeContext);
+            expressionValue = createExpression(exchange.getContext());
         }
         ObjectHelper.notNull(expressionValue, "expressionValue");
         return expressionValue.evaluate(exchange, type);
@@ -128,8 +127,7 @@
 
     public boolean matches(Exchange exchange) {
         if (predicate == null) {
-            RouteContext routeContext = new DefaultRouteContext(exchange.getContext());
-            predicate = createPredicate(routeContext);
+            predicate = createPredicate(exchange.getContext());
         }
         ObjectHelper.notNull(predicate, "predicate");
         return predicate.matches(exchange);
@@ -139,36 +137,42 @@
         return "";
     }
 
-    public Predicate createPredicate(RouteContext routeContext) {
+    public final Predicate createPredicate(RouteContext routeContext) {
+        return createPredicate(routeContext.getCamelContext());
+    }
+
+    public Predicate createPredicate(CamelContext camelContext) {
         if (predicate == null) {
-            if (expressionType != null) {
-                predicate = expressionType.createPredicate(routeContext);
-            } else if (expressionValue != null) {
-                predicate = PredicateBuilder.toPredicate(expressionValue);
+            if (getExpressionType() != null) {
+                predicate = getExpressionType().createPredicate(camelContext);
+            } else if (getExpressionValue() != null) {
+                predicate = PredicateBuilder.toPredicate(getExpressionValue());
             } else if (getExpression() != null) {
                 ObjectHelper.notNull("language", getLanguage());
-                CamelContext camelContext = routeContext.getCamelContext();
                 Language language = camelContext.resolveLanguage(getLanguage());
                 predicate = language.createPredicate(getExpression());
-                configurePredicate(routeContext, predicate);
+                configurePredicate(camelContext, predicate);
             }
         }
         return predicate;
     }
 
-    public Expression createExpression(RouteContext routeContext) {
-        if (expressionValue == null) {
-            if (expressionType != null) {
-                expressionValue = expressionType.createExpression(routeContext);
+    public final Expression createExpression(RouteContext routeContext) {
+        return createExpression(routeContext.getCamelContext());
+    }
+
+    public Expression createExpression(CamelContext camelContext) {
+        if (getExpressionValue() == null) {
+            if (getExpressionType() != null) {
+                setExpressionValue(getExpressionType().createExpression(camelContext));
             } else if (getExpression() != null) {
                 ObjectHelper.notNull("language", getLanguage());
-                CamelContext camelContext = routeContext.getCamelContext();
                 Language language = camelContext.resolveLanguage(getLanguage());
-                expressionValue = language.createExpression(getExpression());
-                configureExpression(routeContext, expressionValue);
+                setExpressionValue(language.createExpression(getExpression()));
+                configureExpression(camelContext, getExpressionValue());
             }
         }
-        return expressionValue;
+        return getExpressionValue();
     }
 
     public String getExpression() {
@@ -237,10 +241,10 @@
         this.expressionType = expressionType;
     }
 
-    protected void configurePredicate(RouteContext routeContext, Predicate predicate) {
+    protected void configurePredicate(CamelContext camelContext, Predicate predicate) {
     }
 
-    protected void configureExpression(RouteContext routeContext, Expression expression) {
+    protected void configureExpression(CamelContext camelContext, Expression expression) {
     }
 
     /**

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/MethodCallExpression.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/MethodCallExpression.java?rev=900466&r1=900465&r2=900466&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/MethodCallExpression.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/MethodCallExpression.java Mon Jan 18 17:15:34 2010
@@ -22,6 +22,7 @@
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlTransient;
 
+import org.apache.camel.CamelContext;
 import org.apache.camel.Expression;
 import org.apache.camel.Predicate;
 import org.apache.camel.language.bean.BeanExpression;
@@ -96,7 +97,7 @@
 
     @SuppressWarnings("unchecked")
     @Override
-    public Expression createExpression(RouteContext routeContext) {
+    public Expression createExpression(CamelContext camelContext) {
         if (beanType != null) {            
             return new BeanExpression(ObjectHelper.newInstance(beanType), getMethod());
         } else if (instance != null) {
@@ -108,7 +109,7 @@
 
     @SuppressWarnings("unchecked")
     @Override
-    public Predicate createPredicate(RouteContext routeContext) {
+    public Predicate createPredicate(CamelContext camelContext) {
         if (beanType != null) {
             return new BeanExpression(ObjectHelper.newInstance(beanType), getMethod());
         } else if (instance != null) {

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/NamespaceAwareExpression.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/NamespaceAwareExpression.java?rev=900466&r1=900465&r2=900466&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/NamespaceAwareExpression.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/NamespaceAwareExpression.java Mon Jan 18 17:15:34 2010
@@ -22,10 +22,10 @@
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlTransient;
 
+import org.apache.camel.CamelContext;
 import org.apache.camel.Expression;
 import org.apache.camel.Predicate;
 import org.apache.camel.spi.NamespaceAware;
-import org.apache.camel.spi.RouteContext;
 
 /**
  * A useful base class for any expression which may be namespace or XML content aware
@@ -60,12 +60,12 @@
     }
 
     @Override
-    protected void configureExpression(RouteContext routeContext, Expression expression) {
+    protected void configureExpression(CamelContext camelContext, Expression expression) {
         configureNamespaceAware(expression);
     }
 
     @Override
-    protected void configurePredicate(RouteContext routeContext, Predicate predicate) {
+    protected void configurePredicate(CamelContext camelContext, Predicate predicate) {
         configureNamespaceAware(predicate);
     }
 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/TokenizerExpression.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/TokenizerExpression.java?rev=900466&r1=900465&r2=900466&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/TokenizerExpression.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/TokenizerExpression.java Mon Jan 18 17:15:34 2010
@@ -21,12 +21,12 @@
 import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlRootElement;
 
+import org.apache.camel.CamelContext;
 import org.apache.camel.Expression;
 import org.apache.camel.language.tokenizer.TokenizeLanguage;
-import org.apache.camel.spi.RouteContext;
 
 /**
- * For expressions and predicates using a body or header tokenzier
+ * For expressions and predicates using a body or header tokenizer
  *
  * @version $Revision$
  */
@@ -73,7 +73,7 @@
     }
 
     @Override
-    public Expression createExpression(RouteContext routeContext) {
+    public Expression createExpression(CamelContext camelContext) {
         TokenizeLanguage language = new TokenizeLanguage();
         language.setToken(token);
         language.setHeaderName(headerName);

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/XPathExpression.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/XPathExpression.java?rev=900466&r1=900465&r2=900466&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/XPathExpression.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/XPathExpression.java Mon Jan 18 17:15:34 2010
@@ -21,9 +21,9 @@
 import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlRootElement;
 
+import org.apache.camel.CamelContext;
 import org.apache.camel.Expression;
 import org.apache.camel.Predicate;
-import org.apache.camel.spi.RouteContext;
 
 /**
  * For XPath expressions and predicates
@@ -56,16 +56,16 @@
     }
 
     @Override
-    protected void configureExpression(RouteContext routeContext, Expression expression) {
-        super.configureExpression(routeContext, expression);
+    protected void configureExpression(CamelContext camelContext, Expression expression) {
+        super.configureExpression(camelContext, expression);
         if (resultType != null) {
             setProperty(expression, "resultType", resultType);
         }
     }
 
     @Override
-    protected void configurePredicate(RouteContext routeContext, Predicate predicate) {
-        super.configurePredicate(routeContext, predicate);
+    protected void configurePredicate(CamelContext camelContext, Predicate predicate) {
+        super.configurePredicate(camelContext, predicate);
         if (resultType != null) {
             setProperty(predicate, "resultType", resultType);
         }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/XQueryExpression.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/XQueryExpression.java?rev=900466&r1=900465&r2=900466&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/XQueryExpression.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/XQueryExpression.java Mon Jan 18 17:15:34 2010
@@ -22,11 +22,11 @@
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlTransient;
 
+import org.apache.camel.CamelContext;
 import org.apache.camel.Expression;
 import org.apache.camel.Predicate;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.spi.ClassResolver;
-import org.apache.camel.spi.RouteContext;
 
 /**
  * For XQuery expressions and predicates
@@ -70,18 +70,18 @@
     }
 
     @Override
-    protected void configureExpression(RouteContext routeContext, Expression expression) {
-        super.configureExpression(routeContext, expression);
-        updateResultType(routeContext.getCamelContext().getClassResolver());
+    protected void configureExpression(CamelContext camelContext, Expression expression) {
+        super.configureExpression(camelContext, expression);
+        updateResultType(camelContext.getClassResolver());
         if (resultType != null) {
             setProperty(expression, "resultType", resultType);
         }
     }
 
     @Override
-    protected void configurePredicate(RouteContext routeContext, Predicate predicate) {
-        super.configurePredicate(routeContext, predicate);
-        updateResultType(routeContext.getCamelContext().getClassResolver());
+    protected void configurePredicate(CamelContext camelContext, Predicate predicate) {
+        super.configurePredicate(camelContext, predicate);
+        updateResultType(camelContext.getClassResolver());
         if (resultType != null) {
             setProperty(predicate, "resultType", resultType);
         }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/builder/NotifyBuilderTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/NotifyBuilderTest.java?rev=900466&r1=900465&r2=900466&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/builder/NotifyBuilderTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/builder/NotifyBuilderTest.java Mon Jan 18 17:15:34 2010
@@ -262,6 +262,26 @@
         assertEquals(true, notify.matches());
     }
 
+    public void testFromFilterBuilderWhenExchangeDone() throws Exception {
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .filter().xpath("/person[@name='James']").whenDone(1)
+                .create();
+
+        assertEquals(false, notify.matches());
+
+        template.sendBody("direct:foo", "<person name='Claus'/>");
+        assertEquals(false, notify.matches());
+
+        template.sendBody("direct:foo", "<person name='Jonathan'/>");
+        assertEquals(false, notify.matches());
+
+        template.sendBody("direct:foo", "<person name='James'/>");
+        assertEquals(true, notify.matches());
+
+        template.sendBody("direct:foo", "<person name='Hadrian'/>");
+        assertEquals(true, notify.matches());
+    }
+
     public void testWhenExchangeCompleted() throws Exception {
         NotifyBuilder notify = new NotifyBuilder(context)
                 .whenCompleted(5)

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/mock/MockAssertionClauseTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/mock/MockAssertionClauseTest.java?rev=900466&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/mock/MockAssertionClauseTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/mock/MockAssertionClauseTest.java Mon Jan 18 17:15:34 2010
@@ -0,0 +1,61 @@
+/**
+ * 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.camel.component.mock;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class MockAssertionClauseTest extends ContextTestSupport {
+
+    public void testAssertionClauseAll() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.allMessages().xpath("/person[@name='James']", Boolean.class);
+
+        template.sendBody("direct:start", "<person name='James' last='Hanson'/>");
+        template.sendBody("direct:start", "<person name='James' last='Jackson'/>");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testAssertionClausePer() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+
+        mock.message(0).xpath("/person[@last='Hanson']", Boolean.class);
+        mock.message(0).body().contains("Hanson");
+
+        mock.message(1).xpath("/person[@last='Jackson']", Boolean.class);
+        mock.message(1).body().contains("Jackson");
+
+        template.sendBody("direct:start", "<person name='James' last='Hanson'/>");
+        template.sendBody("direct:start", "<person name='James' last='Jackson'/>");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("mock:result");
+            }
+        };
+    }
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/mock/MockAssertionClauseTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/mock/MockAssertionClauseTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date