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 cc1057f CAMEL-13151: Removed deprecated property function from simple
language.
cc1057f is described below
commit cc1057f4ad714d075a7d13cc03291395183b8cd7
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Feb 11 17:58:53 2019 +0100
CAMEL-13151: Removed deprecated property function from simple language.
---
MIGRATION.md | 4 ++
...pringSplitterDetermineErrorHandlerIssueTest.xml | 4 +-
core/camel-core/src/main/docs/simple-language.adoc | 57 ++--------------------
.../apache/camel/builder/ExpressionBuilder.java | 8 +--
.../simple/ast/SimpleFunctionExpression.java | 26 +++++-----
.../camel/component/file/FileSplitInSplitTest.java | 8 +--
.../camel/component/file/XPathToFileTest.java | 2 +-
.../apache/camel/language/simple/SimpleTest.java | 24 ++++-----
.../DeadLetterChannelFailureRouteIdTest.java | 2 +-
.../processor/OnExceptionFailureRouteIdTest.java | 2 +-
.../processor/SplitterPropertyContinuedTest.java | 6 +--
11 files changed, 47 insertions(+), 96 deletions(-)
diff --git a/MIGRATION.md b/MIGRATION.md
index 51468be..f62296d 100644
--- a/MIGRATION.md
+++ b/MIGRATION.md
@@ -45,6 +45,10 @@ Deprecated APIs and Components
All deprecated APIs and components from Camel 2.x has been removed in Camel 3.
+#### Simple language
+
+The `property` function was deprecated in Camel 2.x and has been removed. Use
`exchangeProperty` as function name.
+
Migration Camel applications
----------------------------
diff --git
a/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/SpringSplitterDetermineErrorHandlerIssueTest.xml
b/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/SpringSplitterDetermineErrorHandlerIssueTest.xml
index 074c450..901d34f 100644
---
a/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/SpringSplitterDetermineErrorHandlerIssueTest.xml
+++
b/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/SpringSplitterDetermineErrorHandlerIssueTest.xml
@@ -88,8 +88,8 @@
startupOrder="13">
<from uri="direct:HandleException"/>
- <log loggingLevel="INFO" message="[${property.LogPrefix}] EXCEPTION
message: ${exception}"/>
- <log loggingLevel="DEBUG" message="[${property.LogPrefix}] EXCEPTION
stacktrace: ${exception.stacktrace}"/>
+ <log loggingLevel="INFO" message="[${exchangeProperty.LogPrefix}]
EXCEPTION message: ${exception}"/>
+ <log loggingLevel="DEBUG" message="[${exchangeProperty.LogPrefix}]
EXCEPTION stacktrace: ${exception.stacktrace}"/>
<to uri="mock:handled"/>
<stop/>
</route>
diff --git a/core/camel-core/src/main/docs/simple-language.adoc
b/core/camel-core/src/main/docs/simple-language.adoc
index 89c683c..70d167b 100644
--- a/core/camel-core/src/main/docs/simple-language.adoc
+++ b/core/camel-core/src/main/docs/simple-language.adoc
@@ -15,54 +15,20 @@ of expression based script in your Camel routes.
However for much more complex use cases you are generally recommended to
choose a more expressive and powerful language such as:
-* <<spel-language,SpEL>>
-* <<mvel-component,Mvel>>
* <<groovy-language,Groovy>>
-* JavaScript
-* <<el-language,EL>>
+* <<spel-language,SpEL>>
+* <<mvel-component,MVEL>>
* <<ognl-language,OGNL>>
-* one of the supported link:scripting-languages.html[Scripting
-Languages]
The simple language uses `${body`} placeholders for complex expressions
where the expression contains constant literals. The $\{ } placeholders
can be omitted if the expression is only the token itself.
-TIP: *Alternative syntax* From Camel 2.5 onwards you can also use the
alternative syntax which
+TIP: *Alternative syntax* You can also use the alternative syntax which
uses `$simple{ }` as placeholders. This can be used in situations to avoid
clashes when using for example
Spring property placeholder together with Camel.
-=== Simple Language Changes in Camel 2.9 onwards
-
-The <<simple-language,Simple>> language have been improved from Camel 2.9
-onwards to use a better syntax parser, which can do index precise error
-messages, so you know exactly what is wrong and where the problem is.
-For example if you have made a typo in one of the operators, then
-previously the parser would not be able to detect this, and cause the
-evaluation to be true. There are a few changes in the syntax which are
-no longer backwards compatible. When using <<simple-language,Simple>>
-language as a Predicate then the literal text
-*must* be enclosed in either single or double quotes. For example:
-`"${body} == 'Camel'"`. Notice how we have single quotes around the
-literal. The old style of using `"body"` and `"header.foo"` to refer to
-the message body and header is not supported anymore, and it is required to
-always use $\{ } tokens for the built-in functions.
-The range operator now requires the range to be in single quote as well
-as shown: `"${header.zip} between '30000..39999'"`.
-
-To get the body of the in message: `"body"`, or `"in.body"` or
-`"${body}"`.
-
-A complex expression must use $\{ } placeholders, such as:
-`"Hello ${in.header.name} how are you?"`.
-
-You can have multiple functions in the same expression:
-`"Hello ${in.header.name} this is ${in.header.me} speaking"`. +
- However you can *not* nest functions in Camel 2.8.x or older (i.e.
-having another $\{ } placeholder in an existing, is not allowed). +
- From *Camel 2.9* onwards you can nest functions.
-
=== Simple Language options
// language options: START
@@ -169,17 +135,10 @@ classname
|in.headers |Map |*Camel 2.9:* refer to the input headers
-|property.foo |Object |*Deprecated:* refer to the foo property on the exchange
-
|exchangeProperty.foo |Object |*Camel 2.15:* refer to the foo property on the
exchange
-|property[foo] |Object |*Deprecated:* refer to the foo property on the exchange
-
|exchangeProperty[foo] |Object |*Camel 2.15:* refer to the foo property on the
exchange
-|property.foo.*OGNL* |Object |*Deprecated:* refer to the foo property on the
exchange and invoke its
-value using a Camel OGNL expression.
-
|exchangeProperty.foo.*OGNL* |Object |*Camel 2.15:* refer to the foo property
on the exchange and invoke its
value using a Camel OGNL expression.
@@ -219,10 +178,6 @@ Specifying a method name you must use dot as separator. We
also support
the ?method=methodname syntax that is used by the <<bean-component,Bean>>
component.
-|properties:_locations:key_ |String |*Deprecated (use properties-location
instead) Camel 2.3:* Lookup a
-property with the given key. The `locations` option is optional. See
-more at Using PropertyPlaceholder.
-
|properties-location:_http://locationskey[locations:key]_ |String |*Camel
2.14.1:* Lookup a property with the given key. The `locations`
option is optional. See more at
Using PropertyPlaceholder.
@@ -520,12 +475,6 @@ And the following logical operators can be used to group
expressions:
|===
|Operator |Description
-|and |*deprecated* use && instead. The logical and operator is used to group
-two expressions.
-
-|or |*deprecated* use \|\| instead. The logical or operator is used to group
-two expressions.
-
|&& |*Camel 2.9:* The logical and operator is used to group two expressions.
| \|\| |*Camel 2.9:* The logical or operator is used to group two expressions.
diff --git
a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
index 7ac882d..215aa72 100644
---
a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
+++
b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
@@ -1785,10 +1785,10 @@ public final class ExpressionBuilder {
* expressions
*
* @param expressions the expression to be concatenated dynamically
- * @param desription the text description of the expression
+ * @param description the text description of the expression
* @return an expression which when evaluated will return the concatenated
values
*/
- public static Expression concatExpression(final Collection<Expression>
expressions, final String desription) {
+ public static Expression concatExpression(final Collection<Expression>
expressions, final String description) {
return new ExpressionAdapter() {
public Object evaluate(Exchange exchange) {
StringBuilder buffer = new StringBuilder();
@@ -1803,8 +1803,8 @@ public final class ExpressionBuilder {
@Override
public String toString() {
- if (desription != null) {
- return desription;
+ if (description != null) {
+ return description;
} else {
return "concat" + expressions;
}
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 a93d8ab..8b552e3 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
@@ -115,11 +115,8 @@ public class SimpleFunctionExpression extends
LiteralExpression {
return
ExpressionBuilder.exchangeExceptionOgnlExpression(remainder);
}
- // property
- remainder = ifStartsWithReturnRemainder("property", function);
- if (remainder == null) {
- remainder = ifStartsWithReturnRemainder("exchangeProperty",
function);
- }
+ // exchange property
+ remainder = ifStartsWithReturnRemainder("exchangeProperty", function);
if (remainder != null) {
// remove leading character (dot or ?)
if (remainder.startsWith(".") || remainder.startsWith("?")) {
@@ -208,7 +205,12 @@ public class SimpleFunctionExpression extends
LiteralExpression {
if (parts.length > 2) {
throw new SimpleParserException("Valid syntax:
${properties:key[:default]} was: " + function, token.getIndex());
}
- return ExpressionBuilder.propertiesComponentExpression(remainder,
null, null);
+ String defaultValue = null;
+ if (parts.length >= 2) {
+ defaultValue = parts[1];
+ }
+ String key = parts[0];
+ return ExpressionBuilder.propertiesComponentExpression(key, null,
defaultValue);
}
// properties-location: prefix
@@ -218,13 +220,15 @@ public class SimpleFunctionExpression extends
LiteralExpression {
if (parts.length > 3) {
throw new SimpleParserException("Valid syntax:
${properties-location:location:key[:default]} was: " + function,
token.getIndex());
}
-
- String locations = null;
- String key = remainder;
+ String defaultValue = null;
+ if (parts.length >= 3) {
+ defaultValue = parts[2];
+ }
+ String key = null;
if (parts.length >= 2) {
- locations = StringHelper.before(remainder, ":");
- key = StringHelper.after(remainder, ":");
+ key = parts[1];
}
+ String locations = parts[0];
return ExpressionBuilder.propertiesComponentExpression(key,
locations, null);
}
diff --git
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileSplitInSplitTest.java
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileSplitInSplitTest.java
index e528e0a..141b44c 100644
---
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileSplitInSplitTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileSplitInSplitTest.java
@@ -88,15 +88,15 @@ public class FileSplitInSplitTest extends
ContextTestSupport {
.split(body().tokenize(comma))
.parallelProcessing()
.streaming()
- .setProperty("split", new
SimpleExpression("${property.CamelSplitIndex}"))
+ .setProperty("split", new
SimpleExpression("${exchangeProperty.CamelSplitIndex}"))
.split(body().tokenize(LS))
.parallelProcessing()
.streaming()
.setBody(body().append(":Status=OK").append(LS))
-
.to("file:target/data/split/outbox?fileExist=Append&fileName=result${property.split}.txt")
+
.to("file:target/data/split/outbox?fileExist=Append&fileName=result${exchangeProperty.split}.txt")
.end()
- .setBody(new SimpleExpression("${property.split}
complete"))
-
.to("file:target/data/split/outbox?fileExist=Append&fileName=result${property.split}.txt")
+ .setBody(new
SimpleExpression("${exchangeProperty.split} complete"))
+
.to("file:target/data/split/outbox?fileExist=Append&fileName=result${exchangeProperty.split}.txt")
.end().to("mock:result");
}
diff --git
a/core/camel-core/src/test/java/org/apache/camel/component/file/XPathToFileTest.java
b/core/camel-core/src/test/java/org/apache/camel/component/file/XPathToFileTest.java
index 10abda2..ce6bacd 100644
---
a/core/camel-core/src/test/java/org/apache/camel/component/file/XPathToFileTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/component/file/XPathToFileTest.java
@@ -64,7 +64,7 @@ public class XPathToFileTest extends ContextTestSupport {
from("direct:start")
.split(xpath("/foo/person"))
.log("${bodyAs(String)}")
-
.to("file://target/data/xpath?fileName=xpath-${property.CamelSplitIndex}.xml")
+
.to("file://target/data/xpath?fileName=xpath-${exchangeProperty.CamelSplitIndex}.xml")
.to("mock:result");
}
};
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 61bb294..25f5d0f 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
@@ -245,12 +245,6 @@ public class SimpleTest extends LanguageTestSupport {
}
@Test
- public void testSimplePropertyExpressions() throws Exception {
- exchange.setProperty("medal", "gold");
- assertExpression("${property.medal}", "gold");
- }
-
- @Test
public void testSimpleExchangePropertyExpressions() throws Exception {
exchange.setProperty("medal", "gold");
assertExpression("${exchangeProperty.medal}", "gold");
@@ -435,7 +429,7 @@ public class SimpleTest extends LanguageTestSupport {
assertEquals(INDEX_OUT_OF_BOUNDS_ERROR_MSG,
cause.getMessage());
}
}
- assertExpression("${property.unknown[cool]}", null);
+ assertExpression("${exchangeProperty.unknown[cool]}", null);
}
@Test
@@ -446,13 +440,13 @@ public class SimpleTest extends LanguageTestSupport {
map.put("code", 4321);
exchange.setProperty("wicket", map);
- assertExpression("${property.wicket[cool]}", "Camel rocks");
- assertExpression("${property.wicket[dude]}", "Hey dude");
- assertExpression("${property.wicket[unknown]}", null);
- assertExpression("${property.wicket[code]}", 4321);
+ assertExpression("${exchangeProperty.wicket[cool]}", "Camel rocks");
+ assertExpression("${exchangeProperty.wicket[dude]}", "Hey dude");
+ assertExpression("${exchangeProperty.wicket[unknown]}", null);
+ assertExpression("${exchangeProperty.wicket[code]}", 4321);
// no header named unknown
- assertExpression("${property?.unknown[cool]}", null);
- assertExpression("${property.unknown[cool]}", null);
+ assertExpression("${exchangeProperty?.unknown[cool]}", null);
+ assertExpression("${exchangeProperty.unknown[cool]}", null);
}
@Test
@@ -495,10 +489,10 @@ public class SimpleTest extends LanguageTestSupport {
@Test
public void testOGNLPropertyMapIllegalSyntax() throws Exception {
try {
- assertExpression("${property.foobar[bar}", null);
+ assertExpression("${exchangeProperty.foobar[bar}", null);
fail("Should have thrown an exception");
} catch (ExpressionIllegalSyntaxException e) {
- assertTrue(e.getMessage().startsWith("Valid syntax:
${exchangeProperty.OGNL} was: property.foobar[bar at location 0"));
+ assertTrue(e.getMessage().startsWith("Valid syntax:
${exchangeProperty.OGNL} was: exchangeProperty.foobar[bar at location 0"));
}
}
diff --git
a/core/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelFailureRouteIdTest.java
b/core/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelFailureRouteIdTest.java
index 7ba2a90..798aad2 100644
---
a/core/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelFailureRouteIdTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelFailureRouteIdTest.java
@@ -59,7 +59,7 @@ public class DeadLetterChannelFailureRouteIdTest extends
ContextTestSupport {
.throwException(new IllegalArgumentException("Forced"));
from("direct:dead")
- .log("Failed at route ${property.CamelFailureRouteId}")
+ .log("Failed at route
${exchangeProperty.CamelFailureRouteId}")
.to("mock:dead");
}
};
diff --git
a/core/camel-core/src/test/java/org/apache/camel/processor/OnExceptionFailureRouteIdTest.java
b/core/camel-core/src/test/java/org/apache/camel/processor/OnExceptionFailureRouteIdTest.java
index 3174c1e..4b2a4fb 100644
---
a/core/camel-core/src/test/java/org/apache/camel/processor/OnExceptionFailureRouteIdTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/processor/OnExceptionFailureRouteIdTest.java
@@ -40,7 +40,7 @@ public class OnExceptionFailureRouteIdTest extends
DeadLetterChannelFailureRoute
.throwException(new IllegalArgumentException("Forced"));
from("direct:dead")
- .log("Failed at route ${property.CamelFailureRouteId}")
+ .log("Failed at route
${exchangeProperty.CamelFailureRouteId}")
.to("mock:dead");
}
};
diff --git
a/core/camel-core/src/test/java/org/apache/camel/processor/SplitterPropertyContinuedTest.java
b/core/camel-core/src/test/java/org/apache/camel/processor/SplitterPropertyContinuedTest.java
index 5ccfae8..e2367d4 100644
---
a/core/camel-core/src/test/java/org/apache/camel/processor/SplitterPropertyContinuedTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/processor/SplitterPropertyContinuedTest.java
@@ -50,14 +50,14 @@ public class SplitterPropertyContinuedTest extends
ContextTestSupport {
from("direct:start")
.split(body())
- .log("Step #1 - Body: ${body} with error code:
${property.errorCode}")
+ .log("Step #1 - Body: ${body} with error code:
${exchangeProperty.errorCode}")
.choice()
.when(body().contains("Kaboom"))
.throwException(new
IllegalArgumentException("Damn"))
.end()
- .log("Step #2 - Body: ${body} with error code:
${property.errorCode}")
+ .log("Step #2 - Body: ${body} with error code:
${exchangeProperty.errorCode}")
.choice()
- .when(simple("${property.errorCode} != null"))
+ .when(simple("${exchangeProperty.errorCode} !=
null"))
.to("mock:error")
.otherwise()
.to("mock:split")