camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1239623 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/builder/ExpressionBuilder.java main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java test/java/org/apache/camel/language/simple/SimpleTest.java
Date Thu, 02 Feb 2012 14:01:15 GMT
Author: davsclaus
Date: Thu Feb  2 14:01:14 2012
New Revision: 1239623

URL: http://svn.apache.org/viewvc?rev=1239623&view=rev
Log:
CAMEL-4971: Added camelId to simple language as a known function

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java?rev=1239623&r1=1239622&r2=1239623&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java Thu
Feb  2 14:01:14 2012
@@ -442,6 +442,24 @@ public final class ExpressionBuilder {
     }
 
     /**
+     * Returns an expression for the {@link org.apache.camel.CamelContext} name
+     *
+     * @return an expression object which will return the camel context name
+     */
+    public static Expression camelContextNameExpression() {
+        return new ExpressionAdapter() {
+            public Object evaluate(Exchange exchange) {
+                return exchange.getContext().getName();
+            }
+
+            @Override
+            public String toString() {
+                return "camelContextName";
+            }
+        };
+    }
+
+    /**
      * Returns an expression for an exception message set on the exchange
      *
      * @see <tt>Exchange.getException().getMessage()</tt>

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java?rev=1239623&r1=1239622&r2=1239623&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
Thu Feb  2 14:01:14 2012
@@ -275,6 +275,8 @@ public class SimpleFunctionExpression ex
             return ExpressionBuilder.exchangeExceptionStackTraceExpression();
         } else if (ObjectHelper.equal(expression, "threadName")) {
             return ExpressionBuilder.threadNameExpression();
+        } else if (ObjectHelper.equal(expression, "camelId")) {
+            return ExpressionBuilder.camelContextNameExpression();
         }
 
         return null;

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java?rev=1239623&r1=1239622&r2=1239623&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
Thu Feb  2 14:01:14 2012
@@ -135,7 +135,11 @@ public class SimpleTest extends Language
             assertExpression("sysenv.PATH", path);
         }
     }
-    
+
+    public void testSimpleCamelId() throws Exception {
+        assertExpression("camelId", context.getName());
+    }
+
     public void testOGNLBodyListAndMap() throws Exception {
         Map<String, Object> map = new HashMap<String, Object>();
         map.put("cool", "Camel rocks");



Mime
View raw message