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 2019/05/16 07:08:36 UTC

[camel] branch master updated: CAMEL-13531: Simple language - Add env as function to lookup system env variable

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 1ee4559  CAMEL-13531: Simple language - Add env as function to lookup system env variable
1ee4559 is described below

commit 1ee45591aa7b653243d22507392bb12ffdc30836
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu May 16 09:08:19 2019 +0200

    CAMEL-13531: Simple language - Add env as function to lookup system env variable
---
 core/camel-core/src/main/docs/simple-language.adoc                  | 6 ++++--
 .../apache/camel/language/simple/ast/SimpleFunctionExpression.java  | 3 +++
 .../src/test/java/org/apache/camel/language/simple/SimpleTest.java  | 3 +++
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/core/camel-core/src/main/docs/simple-language.adoc b/core/camel-core/src/main/docs/simple-language.adoc
index 34f46b6..aa063ff 100644
--- a/core/camel-core/src/main/docs/simple-language.adoc
+++ b/core/camel-core/src/main/docs/simple-language.adoc
@@ -142,9 +142,11 @@ classname
 |exchangeProperty.foo.*OGNL* |Object |refer to the foo property on the exchange and invoke its
 value using a Camel OGNL expression.
 
-|sys.foo |String |refer to the system property
+|sys.foo |String |refer to the JVM system property
 
-|sysenv.foo |String |refer to the system environment
+|sysenv.foo |String |refer to the system environment variable
+
+|env.foo |String |refer to the system environment variable
 
 |exception |Object |refer to the exception object on the exchange, is *null* if
 no exception set on exchange. Will fallback and grab caught exceptions
diff --git a/core/camel-core/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java b/core/camel-core/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
index 96c6bbc..c3e2a01 100644
--- a/core/camel-core/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
+++ b/core/camel-core/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
@@ -149,6 +149,9 @@ public class SimpleFunctionExpression extends LiteralExpression {
             return ExpressionBuilder.systemPropertyExpression(remainder);
         }
         remainder = ifStartsWithReturnRemainder("sysenv.", function);
+        if (remainder == null) {
+            remainder = ifStartsWithReturnRemainder("env.", function);
+        }
         if (remainder != null) {
             return ExpressionBuilder.systemEnvironmentExpression(remainder);
         }
diff --git a/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java b/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
index 84ddf99..39d09e1 100644
--- a/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
@@ -268,6 +268,7 @@ public class SimpleTest extends LanguageTestSupport {
         String path = System.getenv("PATH");
         if (path != null) {
             assertExpression("${sysenv.PATH}", path);
+            assertExpression("${env.PATH}", path);
         }
     }
     
@@ -276,6 +277,7 @@ public class SimpleTest extends LanguageTestSupport {
         String foo = System.getenv("FOO_SERVICE_HOST");
         if (foo != null) {
             assertExpression("${sysenv.FOO-SERVICE-HOST}", foo);
+            assertExpression("${env.FOO-SERVICE-HOST}", foo);
         }
     }
 
@@ -284,6 +286,7 @@ public class SimpleTest extends LanguageTestSupport {
         String path = System.getenv("PATH");
         if (path != null) {
             assertExpression("${sysenv.path}", path);
+            assertExpression("${env.path}", path);
         }
     }