camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r751450 - in /camel/trunk/camel-core/src/main/java/org/apache/camel: builder/ language/bean/ language/simple/
Date Sun, 08 Mar 2009 15:58:09 GMT
Author: davsclaus
Date: Sun Mar  8 15:58:08 2009
New Revision: 751450

URL: http://svn.apache.org/viewvc?rev=751450&view=rev
Log:
Reduced package tangling. And moved a builder into the builder package where it belongs.

Added:
    camel/trunk/camel-core/src/main/java/org/apache/camel/builder/FileExpressionBuilder.java
  (contents, props changed)
      - copied, changed from r751401, camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/FileExpressionBuilder.java
Removed:
    camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/FileExpressionBuilder.java
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/language/bean/BeanExpression.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/FileLanguage.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguageSupport.java

Copied: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/FileExpressionBuilder.java
(from r751401, camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/FileExpressionBuilder.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/FileExpressionBuilder.java?p2=camel/trunk/camel-core/src/main/java/org/apache/camel/builder/FileExpressionBuilder.java&p1=camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/FileExpressionBuilder.java&r1=751401&r2=751450&rev=751450&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/FileExpressionBuilder.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/FileExpressionBuilder.java
Sun Mar  8 15:58:08 2009
@@ -15,24 +15,23 @@
  * limitations under the License.
  */
 
-package org.apache.camel.language.simple;
+package org.apache.camel.builder;
 
 import java.text.SimpleDateFormat;
 import java.util.Date;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Expression;
-import org.apache.camel.builder.ExpressionBuilder;
 import org.apache.camel.impl.ExpressionAdapter;
 import org.apache.camel.language.IllegalSyntaxException;
 import org.apache.camel.language.constant.ConstantLanguage;
-import org.apache.camel.util.FileUtil;
+import org.apache.camel.language.simple.SimpleLanguage;
 
 /**
  * A helper class for working with <a href="http://camel.apache.org/expression.html">expressions</a>
based
  * on files.
  * <p/>
- * This expression expects the headers from the {@link FileLanguage} on the <b>IN</b>
message.
+ * This expression expects the headers from the {@link org.apache.camel.language.simple.FileLanguage}
on the <b>IN</b> message.
  *
  * @see org.apache.camel.language.simple.FileLanguage
  */

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

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

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/language/bean/BeanExpression.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/language/bean/BeanExpression.java?rev=751450&r1=751449&r2=751450&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/language/bean/BeanExpression.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/language/bean/BeanExpression.java
Sun Mar  8 15:58:08 2009
@@ -18,18 +18,20 @@
 
 import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePattern;
+import org.apache.camel.Expression;
+import org.apache.camel.Predicate;
 import org.apache.camel.component.bean.BeanHolder;
 import org.apache.camel.component.bean.BeanProcessor;
 import org.apache.camel.component.bean.ConstantBeanHolder;
 import org.apache.camel.component.bean.RegistryBean;
-import org.apache.camel.impl.ExpressionSupport;
+import org.apache.camel.util.ObjectHelper;
 
 /**
  * Evaluates an expression using a bean method invocation
  *
  * @version $Revision$
  */
-public class BeanExpression extends ExpressionSupport {
+public class BeanExpression implements Expression, Predicate {
     private String beanName;
     private String method;
     private Object bean;
@@ -79,4 +81,17 @@
             throw new RuntimeBeanExpressionException(exchange, beanName, method, e);
         }
     }
+
+    public <T> T evaluate(Exchange exchange, Class<T> type) {
+        Object result = evaluate(exchange);
+        return exchange.getContext().getTypeConverter().convertTo(type, result);
+    }
+
+    public boolean matches(Exchange exchange) {
+        Object value = evaluate(exchange);
+        return ObjectHelper.evaluateValuePredicate(value);
+    }
+
+    public void assertMatches(String text, Exchange exchange) throws AssertionError {
+    }
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/FileLanguage.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/FileLanguage.java?rev=751450&r1=751449&r2=751450&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/FileLanguage.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/FileLanguage.java
Sun Mar  8 15:58:08 2009
@@ -17,6 +17,7 @@
 package org.apache.camel.language.simple;
 
 import org.apache.camel.Expression;
+import org.apache.camel.builder.FileExpressionBuilder;
 import org.apache.camel.language.IllegalSyntaxException;
 import org.apache.camel.util.ObjectHelper;
 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguageSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguageSupport.java?rev=751450&r1=751449&r2=751450&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguageSupport.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguageSupport.java
Sun Mar  8 15:58:08 2009
@@ -28,7 +28,6 @@
 import org.apache.camel.builder.ExpressionBuilder;
 import org.apache.camel.builder.PredicateBuilder;
 import org.apache.camel.builder.ValueBuilder;
-import org.apache.camel.impl.ExpressionAdapter;
 import org.apache.camel.spi.Language;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.commons.logging.Log;
@@ -97,8 +96,7 @@
             rightConverted = ExpressionBuilder.convertToExpression(right, left);
         }
 
-        return new ExpressionAdapter() {
-            @Override
+        return new Expression() {
             public Object evaluate(final Exchange exchange) {
                 Predicate predicate = null;
                 if (operator == EQ) {
@@ -147,6 +145,11 @@
                 return predicate.matches(exchange);
             }
 
+            public <T> T evaluate(Exchange exchange, Class<T> type) {
+                Object result = evaluate(exchange);
+                return exchange.getContext().getTypeConverter().convertTo(type, result);
+            }
+
             @Override
             public String toString() {
                 return left + " " + operator + " " + right;



Mime
View raw message