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 2021/09/13 09:17:59 UTC
[camel] branch main updated: CAMEL-16861: polish core language docs.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 8299fe7 CAMEL-16861: polish core language docs.
8299fe7 is described below
commit 8299fe735b37ab40b75ac00746709b9faffd7dc5
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Sep 13 11:17:22 2021 +0200
CAMEL-16861: polish core language docs.
---
.../apache/camel/catalog/languages/constant.json | 1 +
.../org/apache/camel/catalog/languages/file.json | 2 +-
.../org/apache/camel/catalog/models/constant.json | 1 +
.../org/apache/camel/language/simple/file.json | 2 +-
.../modules/languages/pages/csimple-language.adoc | 12 +-
.../languages/pages/exchangeProperty-language.adoc | 21 +--
.../modules/languages/pages/file-language.adoc | 108 +++----------
.../modules/languages/pages/header-language.adoc | 26 +---
.../docs/modules/languages/pages/ref-language.adoc | 12 +-
.../modules/languages/pages/simple-language.adoc | 169 +++++++--------------
.../modules/languages/pages/tokenize-language.adoc | 34 ++++-
.../apache/camel/language/simple/FileLanguage.java | 2 +-
.../modules/languages/pages/csimple-language.adoc | 12 +-
.../languages/pages/exchangeProperty-language.adoc | 21 +--
.../modules/languages/pages/file-language.adoc | 108 +++----------
.../modules/languages/pages/header-language.adoc | 26 +---
.../modules/languages/pages/ref-language.adoc | 12 +-
.../modules/languages/pages/simple-language.adoc | 169 +++++++--------------
.../modules/languages/pages/tokenize-language.adoc | 34 ++++-
.../camel/maven/packaging/PackageLanguageMojo.java | 2 +-
20 files changed, 264 insertions(+), 510 deletions(-)
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/constant.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/constant.json
index e95a81b..35bfc3a 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/constant.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/constant.json
@@ -17,6 +17,7 @@
},
"properties": {
"expression": { "kind": "value", "displayName": "Expression", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The expression value in your chosen language syntax" },
+ "resultType": { "kind": "attribute", "displayName": "Result Type", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the class name of the constant type" },
"trim": { "kind": "attribute", "displayName": "Trim", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to trim the value to remove leading and trailing whitespaces and line breaks" },
"id": { "kind": "attribute", "displayName": "Id", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the id of this node" }
}
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/file.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/file.json
index 3e05125..396c930 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/file.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/file.json
@@ -3,7 +3,7 @@
"kind": "language",
"name": "file",
"title": "File",
- "description": "File related capabilities for the Simle language",
+ "description": "File related capabilities for the Simple language",
"deprecated": false,
"firstVersion": "1.1.0",
"label": "language,core,java",
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/constant.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/constant.json
index 8ac4fb5..8ef0d74 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/constant.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/constant.json
@@ -13,6 +13,7 @@
},
"properties": {
"expression": { "kind": "value", "displayName": "Expression", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The expression value in your chosen language syntax" },
+ "resultType": { "kind": "attribute", "displayName": "Result Type", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the class name of the constant type" },
"trim": { "kind": "attribute", "displayName": "Trim", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to trim the value to remove leading and trailing whitespaces and line breaks" },
"id": { "kind": "attribute", "displayName": "Id", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the id of this node" }
}
diff --git a/core/camel-core-languages/src/generated/resources/org/apache/camel/language/simple/file.json b/core/camel-core-languages/src/generated/resources/org/apache/camel/language/simple/file.json
index 3e05125..396c930 100644
--- a/core/camel-core-languages/src/generated/resources/org/apache/camel/language/simple/file.json
+++ b/core/camel-core-languages/src/generated/resources/org/apache/camel/language/simple/file.json
@@ -3,7 +3,7 @@
"kind": "language",
"name": "file",
"title": "File",
- "description": "File related capabilities for the Simle language",
+ "description": "File related capabilities for the Simple language",
"deprecated": false,
"firstVersion": "1.1.0",
"label": "language,core,java",
diff --git a/core/camel-core-languages/src/main/docs/modules/languages/pages/csimple-language.adoc b/core/camel-core-languages/src/main/docs/modules/languages/pages/csimple-language.adoc
index 4010feb..aecbc90 100644
--- a/core/camel-core-languages/src/main/docs/modules/languages/pages/csimple-language.adoc
+++ b/core/camel-core-languages/src/main/docs/modules/languages/pages/csimple-language.adoc
@@ -18,13 +18,13 @@ The simple language is a dynamic expression language which is runtime parsed int
The csimple language is parsed into regular Java source code and compiled together with all the other source code,
or compiled once during bootstrap via the `camel-csimple-joor` module.
-The simple langauge is generally very lightweight and fast, however for some use-cases with dynamic method calls via OGNL paths,
+The simple language is generally very lightweight and fast, however for some use-cases with dynamic method calls via OGNL paths,
then the simple language does runtime introspection and reflection calls. This has an overhead on performance,
and was one of the reasons why csimple was created.
The csimple language requires to be typesafe and method calls via OGNL paths requires to know the type during parsing.
This means for csimple languages expressions you would need to provide the class type in the script,
-where as simple introspects this at runtime.
+whereas simple introspects this at runtime.
In other words the simple language is using _duck typing_ (if it looks like a duck, and quacks like a duck, then it is a duck)
and csimple is using Java type (typesafety). If there is a type error then simple will report this at runtime,
@@ -86,14 +86,14 @@ There are two ways to compile csimple
=== Using camel-csimple-maven-plugin
-The `camel-csimple-maven-plugin` Maven plugin is used for discoving all the csimple scripts from the source code, and then automatic generate source code in the `src/generated/java` folder, which then gets compiled together with all the other sources.
+The `camel-csimple-maven-plugin` Maven plugin is used for discovering all the csimple scripts from the source code, and then automatic generate source code in the `src/generated/java` folder, which then gets compiled together with all the other sources.
The maven plugin will do source code scanning of `.java` and `.xml` files (Java and XML DSL).
The scanner limits to detect certain code patterns, and it may miss discovering some csimple scripts if they are being used in unusual/rare ways.
The runtime compilation using `camel-csimple-joor` does not have this limitation.
-However the pros is that all of the csimple scripts will be compiled using the regular Java compiler and therefore everything
+The benefit is all the csimple scripts will be compiled using the regular Java compiler and therefore everything
is included out of the box as `.class` files in the application JAR file, and no additional dependencies is required at runtime.
To use `camel-csimple-maven-plugin` you need to add it to your `pom.xml` file as shown:
@@ -190,7 +190,7 @@ The CSimple language supports 2 options, which are listed below.
== Limitations
-Currently the csimple language does **not** support:
+Currently, the csimple language does **not** support:
- nested functions (aka functions inside functions)
- the _null safe_ operator (`?`).
@@ -209,7 +209,7 @@ For example the following scripts cannot compile:
== Auto imports
-The csimple language will automatic import from:
+The csimple language will automatically import from:
[source,java]
----
diff --git a/core/camel-core-languages/src/main/docs/modules/languages/pages/exchangeProperty-language.adoc b/core/camel-core-languages/src/main/docs/modules/languages/pages/exchangeProperty-language.adoc
index 90d46a1..68ac426 100644
--- a/core/camel-core-languages/src/main/docs/modules/languages/pages/exchangeProperty-language.adoc
+++ b/core/camel-core-languages/src/main/docs/modules/languages/pages/exchangeProperty-language.adoc
@@ -26,13 +26,9 @@ The ExchangeProperty language supports 1 options, which are listed below.
|===
// language options: END
-== Example usage
+== Example
-The recipientList element of the Spring DSL can utilize a
-exchangeProperty expression like:
-
-In this case, the list of recipients are contained in the property
-'myProperty'.
+The `recipientList` EIP can utilize a exchangeProperty like:
[source,xml]
----
@@ -44,6 +40,9 @@ In this case, the list of recipients are contained in the property
</route>
----
+In this case, the list of recipients are contained in the property
+'myProperty'.
+
And the same example in Java DSL:
[source,java]
@@ -51,16 +50,6 @@ And the same example in Java DSL:
from("direct:a").recipientList(exchangeProperty("myProperty"));
----
-And with a slightly different syntax where you use the builder to the
-fullest (i.e. avoid using parameters but using stacked operations,
-notice that exchangeProperty is not a parameter but a stacked method
-call)
-
-[source,java]
-----
-from("direct:a").recipientList().exchangeProperty("myProperty");
-----
-
== Dependencies
The ExchangeProperty language is part of *camel-core*.
diff --git a/core/camel-core-languages/src/main/docs/modules/languages/pages/file-language.adoc b/core/camel-core-languages/src/main/docs/modules/languages/pages/file-language.adoc
index 38bf503..cb295b8 100644
--- a/core/camel-core-languages/src/main/docs/modules/languages/pages/file-language.adoc
+++ b/core/camel-core-languages/src/main/docs/modules/languages/pages/file-language.adoc
@@ -2,23 +2,25 @@
= File Language
:docTitle: File
:artifactId: camel-core-languages
-:description: File related capabilities for the Simle language
+:description: File related capabilities for the Simple language
:since: 1.1
:supportLevel: Stable
include::{cq-version}@camel-quarkus:ROOT:partial$reference/languages/file.adoc[opts=optional]
*Since Camel {since}*
-The file language is merged with
-xref:simple-language.adoc[Simple] language which means you can use all the file
-syntax directly within the simple language.
-
The File Expression Language is an extension to the
xref:simple-language.adoc[Simple] language, adding file related capabilities.
These capabilities are related to common use cases working with file
path and names. The goal is to allow expressions to be used with the
-File and FTP components for setting
-dynamic file patterns for both consumer and producer.
+
+xref:components::file-component.adoc[File] and xref:components::ftp-component.adoc[FTP]
+components for setting dynamic file patterns for both consumer and producer.
+
+NOTE: The file language is merged with
+xref:simple-language.adoc[Simple] language which means you can use all the file
+syntax directly within the simple language.
+
== File Language options
@@ -39,19 +41,13 @@ The File language supports 2 options, which are listed below.
This language is an *extension* to the xref:simple-language.adoc[Simple] language
so the xref:simple-language.adoc[Simple] syntax applies also. So the table below
-only lists the additional. +
- As opposed to xref:simple-language.adoc[Simple] language
-xref:file-language.adoc[File Language] also supports
-xref:constant-language.adoc[Constant] expressions so you can enter a fixed
-filename.
+only lists the additional file related functions.
All the file tokens use the same expression name as the method on the
`java.io.File` object, for instance `file:absolute` refers to the
`java.io.File.getAbsolute()` method. Notice that not all expressions are
supported by the current Exchange. For instance the xref:components::ftp-component.adoc[FTP]
-component supports some of the options, where as the
-File component supports all of them.
-
+component supports some options, whereas the File component supports all of them.
[width="100%",cols="10%,10%,10%,10%,10%,25%,25%",options="header",]
|===
@@ -63,7 +59,7 @@ below)
|file:name.ext |String |yes |no |yes |no |refers to the file extension only
|file:name.ext.single |String |yes |no |yes |no |refers to the file extension. If the file
-extension has mutiple dots, then this expression strips and only returns
+extension has multiple dots, then this expression strips and only returns
the last part.
|file:name.noext |String |yes |no |yes |no |refers to the file name with no extension (is relative to the starting
@@ -176,17 +172,16 @@ return as:
== Samples
-You can enter a fixed xref:constant-language.adoc[Constant] expression such as
-`myfile.txt`:
+You can enter a fixed file name such as `myfile.txt`:
[source]
----
fileName="myfile.txt"
----
-Lets assume we use the file consumer to read files and want to move the
-read files to backup folder with the current date as a sub folder. This
-can be archieved using an expression like:
+Let's assume we use the file consumer to read files and want to move the
+read files to back up folder with the current date as a sub folder. This
+can be done using an expression like:
[source]
----
@@ -194,7 +189,7 @@ fileName="backup/${date:now:yyyyMMdd}/${file:name.noext}.bak"
----
relative folder names are also supported so suppose the backup folder
-should be a sibling folder then you can append .. as:
+should be a sibling folder then you can append `..` as shown:
[source]
----
@@ -211,8 +206,8 @@ expression:
fileName="../backup/${date:now:yyyyMMdd}/type-${in.header.type}/backup-of-${file:name.noext}.bak"
----
-If you have a custom Date you want to use in the expression then Camel
-supports retrieving dates from the message header.
+If you have a custom date you want to use in the expression then Camel
+supports retrieving dates from the message header:
[source]
----
@@ -227,74 +222,11 @@ that generates some String output (or convertible to String) to be used:
fileName="uniquefile-${bean:myguidgenerator.generateid}.txt"
----
-And of course all this can be combined in one expression where you can
+Of course all this can be combined in one expression where you can
use the xref:file-language.adoc[File Language], xref:file-language.adoc[Simple]
and the xref:components::bean-component.adoc[Bean] language in one combined expression. This
is pretty powerful for those common file path patterns.
-== Using Spring PropertyPlaceholderConfigurer together with the File component
-
-In Camel you can use the xref:file-language.adoc[File Language] directly
-from the xref:simple-language.adoc[Simple] language which makes a
-Content Based Router easier to do in
-Spring XML, where we can route based on file extensions as shown below:
-
-[source,xml]
-----
-<from uri="file://input/orders"/>
- <choice>
- <when>
- <simple>${file:ext} == 'txt'</simple>
- <to uri="bean:orderService?method=handleTextFiles"/>
- </when>
- <when>
- <simple>${file:ext} == 'xml'</simple>
- <to uri="bean:orderService?method=handleXmlFiles"/>
- </when>
- <otherwise>
- <to uri="bean:orderService?method=handleOtherFiles"/>
- </otherwise>
- </choice>
-----
-
-If you use the `fileName` option on the File endpoint
-to set a dynamic filename using the xref:file-language.adoc[File Language] then make sure you +
- use the alternative syntax to avoid
-clashing with Springs `PropertyPlaceholderConfigurer`.
-
-*bundle-context.xml*
-
-[source,xml]
-----
-<bean id="propertyPlaceholder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
- <property name="location" value="classpath:bundle-context.cfg" />
-</bean>
-
-<bean id="sampleRoute" class="SampleRoute">
- <property name="fromEndpoint" value="${fromEndpoint}" />
- <property name="toEndpoint" value="${toEndpoint}" />
-</bean>
-----
-
-*bundle-context.cfg*
-
-[source]
-----
-fromEndpoint=activemq:queue:test
-toEndpoint=file://fileRoute/out?fileName=test-$simple{date:now:yyyyMMdd}.txt
-----
-
-Notice how we use the $simple\{ } syntax in the `toEndpoint` above. +
- If you don't do this, there is a clash and Spring will throw an
-exception like
-
-[source,java]
-----------------------------------------------------------------------------------------------------
-org.springframework.beans.factory.BeanDefinitionStoreException:
-Invalid bean definition with name 'sampleRoute' defined in class path resource [bundle-context.xml]:
-Could not resolve placeholder 'date:now:yyyyMMdd'
-----------------------------------------------------------------------------------------------------
-
== Dependencies
The File language is part of *camel-core*.
diff --git a/core/camel-core-languages/src/main/docs/modules/languages/pages/header-language.adoc b/core/camel-core-languages/src/main/docs/modules/languages/pages/header-language.adoc
index 1a68aa2..96c9b71 100644
--- a/core/camel-core-languages/src/main/docs/modules/languages/pages/header-language.adoc
+++ b/core/camel-core-languages/src/main/docs/modules/languages/pages/header-language.adoc
@@ -28,19 +28,16 @@ The Header language supports 1 options, which are listed below.
== Example usage
-== Example usage
-
-The recipientList element of the Spring DSL can utilize a header
-expression like:
+The `recipientList` EIP can utilize a header:
[source,xml]
----
- <route>
- <from uri="direct:a" />
- <recipientList>
- <header>myHeader</header>
- </recipientList>
- </route>
+<route>
+ <from uri="direct:a" />
+ <recipientList>
+ <header>myHeader</header>
+ </recipientList>
+</route>
----
In this case, the list of recipients are contained in the header
@@ -53,15 +50,6 @@ And the same example in Java DSL:
from("direct:a").recipientList(header("myHeader"));
----
-And with a slightly different syntax where you use the builder to the
-fullest (i.e. avoid using parameters but using stacked operations,
-notice that header is not a parameter but a stacked method call)
-
-[source,java]
-----
-from("direct:a").recipientList().header("myHeader");
-----
-
== Dependencies
The Header language is part of *camel-core*.
diff --git a/core/camel-core-languages/src/main/docs/modules/languages/pages/ref-language.adoc b/core/camel-core-languages/src/main/docs/modules/languages/pages/ref-language.adoc
index a367a7a..67ddbe0 100644
--- a/core/camel-core-languages/src/main/docs/modules/languages/pages/ref-language.adoc
+++ b/core/camel-core-languages/src/main/docs/modules/languages/pages/ref-language.adoc
@@ -10,7 +10,7 @@ include::{cq-version}@camel-quarkus:ROOT:partial$reference/languages/ref.adoc[op
*Since Camel {since}*
The Ref Expression Language is really just a way to lookup a custom
-Expression or Predicate from the Registry.
+`Expression` or `Predicate` from the xref:latest@manual:ROOT:registry.adoc[Registry].
This is particular useable in XML DSLs.
@@ -30,7 +30,7 @@ The Ref language supports 1 options, which are listed below.
== Example usage
-The Splitter in XML DSL can utilize a custom
+The Splitter EIP in XML DSL can utilize a custom
expression using `<ref>` like:
[source,xml]
@@ -46,10 +46,10 @@ expression using `<ref>` like:
</route>
----
-in this case, the Message coming from the seda:a
-Endpoint will be splitted using a custom
-Expression which has the id `myExpression` in the
-Registry.
+in this case, the message coming from the seda:a
+endpoint will be splitted using a custom
+`Expression` which has the id `myExpression` in the
+xref:latest@manual:ROOT:registry.adoc[Registry].
And the same example using Java DSL:
diff --git a/core/camel-core-languages/src/main/docs/modules/languages/pages/simple-language.adoc b/core/camel-core-languages/src/main/docs/modules/languages/pages/simple-language.adoc
index d811592..cb4d933 100644
--- a/core/camel-core-languages/src/main/docs/modules/languages/pages/simple-language.adoc
+++ b/core/camel-core-languages/src/main/docs/modules/languages/pages/simple-language.adoc
@@ -12,14 +12,13 @@ include::{cq-version}@camel-quarkus:ROOT:partial$reference/languages/simple.adoc
The Simple Expression Language was a really simple language when it was
created, but has since grown more powerful. It is primarily intended for
being a very small and simple language for evaluating
-Expressions and Predicates
-without requiring any new dependencies or knowledge of
-xref:xpath-language.adoc[XPath]; so it is ideal for testing in camel-core. The
-idea was to cover 95% of the common use cases when you need a little bit
-of expression based script in your Camel routes.
+`Expression` or `Predicate` without requiring any new dependencies
+or knowledge of other scripting languages such as Groovy.
-However for much more complex use cases you are generally recommended to
-choose a more expressive and powerful language such as:
+The simple langauge is designed with intend to cover almost all of the common use cases
+when little need for scripting in your Camel routes.
+
+However, for much more complex use cases then a more powerful language is recommended such as:
* xref:groovy-language.adoc[Groovy]
* xref:mvel-language.adoc[MVEL]
@@ -80,9 +79,9 @@ OGNL expression.
|exchangeId |String |the exchange id
-|id |String |the input message id
+|id |String |the message id
-|messageTimestamp |String |the input message timestamp (millis since epoc) that this message originates from.
+|messageTimestamp |String |the message timestamp (millis since epoc) that this message originates from.
Some systems like JMS, Kafka, AWS have a timestamp on the event/message, that Camel received. This method returns
the timestamp, if a timestamp exists.
The message timestamp and exchange created are not the same. An exchange always have a created timestamp which is the
@@ -90,13 +89,9 @@ local timestamp when Camel created the exchange. The message timestamp is only a
when the consumer is able to extract the timestamp from the source event.
If the message has no timestamp then 0 is returned.
-|body |Object |the input body
-
-|in.body |Object |*deprecated* the input body
+|body |Object |the body
-|body.*OGNL* |Object |the input body invoked using a Camel OGNL expression.
-
-|in.body.*OGNL* |Object |*deprecated* the input body invoked using a Camel OGNL expression.
+|body.*OGNL* |Object |the body invoked using a Camel OGNL expression.
|bodyAs(_type_) |Type |Converts the body to the given type determined by its
classname. The converted body can be null.
@@ -113,54 +108,26 @@ classname, and expects the body to be not null.
|mandatoryBodyAs(_type_).*OGNL* |Object |Converts the body to the given type determined by its
classname and then invoke methods using a Camel OGNL expression.
-|header.foo |Object |refer to the input foo header
-
-|header:foo |Object |refer to the input foo header
-
-|header[foo] |Object |refer to the input foo header
-
-|headers.foo |Object |refer to the input foo header
-
-|headers:foo |Object |refer to the input foo header
-
-|headers[foo] |Object |refer to the input foo header
+|header.foo |Object |refer to the foo header
-|in.header.foo |Object |*deprecated* refer to the input foo header
+|header[foo] |Object |refer to the foo header
-|in.header:foo |Object |*deprecated* refer to the input foo header
+|headers.foo |Object |refer to the foo header
-|in.header[foo] |Object |*deprecated* refer to the input foo header
+|headers:foo |Object |refer to the foo header
-|in.headers.foo |Object |*deprecated* refer to the input foo header
+|headers[foo] |Object |refer to the foo header
-|in.headers:foo |Object |*deprecated* refer to the input foo header
-
-|in.headers[foo] |Object |*deprecated* refer to the input foo header
-
-|header.foo[bar] |Object |regard input foo header as a map and perform lookup on the
-map with bar as key
-
-|in.header.foo[bar] |Object |*deprecated* regard input foo header as a map and perform lookup on the
+|header.foo[bar] |Object |regard foo header as a map and perform lookup on the
map with bar as key
-|in.headers.foo[bar] |Object |*deprecated* regard input foo header as a map and perform lookup on the
-map with bar as key
-
-|header.foo.*OGNL* |Object |refer to the input foo header and invoke its value using a
-Camel OGNL expression.
-
-|in.header.foo.*OGNL* |Object |*deprecated* refer to the input foo header and invoke its value using a
-Camel OGNL expression.
-
-|in.headers.foo.*OGNL* |Object |*deprecated* refer to the input foo header and invoke its value using a
+|header.foo.*OGNL* |Object |refer to the foo header and invoke its value using a
Camel OGNL expression.
|headerAs(_key_,_type_) |Type |converts the header to the given type determined by its
classname
-|headers |Map |refer to the input headers
-
-|in.headers |Map |*deprecated* refer to the input headers
+|headers |Map |refer to the headers
|exchangeProperty.foo |Object |refer to the foo property on the exchange
@@ -227,7 +194,7 @@ logging purpose.
the given id.
|type:name.field |Object |To refer to a type or field by its FQN name. To refer to a
-field you can append .FIELD_NAME. For example you can refer to the
+field you can append .FIELD_NAME. For example, you can refer to the
constant field from Exchange as: `org.apache.camel.Exchange.FILE_NAME`
|null |null |represents a *null*
@@ -253,7 +220,7 @@ been routed. This is similar to the route stack-trace message history
the error handler logs in case of an unhandled exception.
|messageHistory(false) |String |As messageHistory but without the exchange details (only
-includes the route strack-trace). This can be used if you do not want to
+includes the route stack-trace). This can be used if you do not want to
log sensitive data from the message itself.
|=======================================================================
@@ -401,13 +368,13 @@ ${leftValue} OP rightValue
--------------------------
Where the `rightValue` can be a String literal enclosed in `' '`,
-`null`, a constant value or another expression enclosed in $\{ }.
+`null`, a constant value or another expression enclosed in `$\{ }`.
IMPORTANT: There *must* be spaces around the operator.
Camel will automatically type convert the rightValue type to the
-leftValue type, so it is able to eg. convert a string into a numeric so
-you can use > comparison for numeric values.
+leftValue type, so it is able to eg. convert a string into a numeric, so
+you can use `>` comparison for numeric values.
The following operators are supported:
@@ -453,9 +420,9 @@ is a set of four values with an empty value and then the three medals.
by comma. If you want to include an empty value, then it must be defined using double comma, eg ',,bronze,silver,gold', which
is a set of four values with an empty value and then the three medals.
-|is |For matching if the left hand side type is an instanceof the value.
+|is |For matching if the left hand side type is an instance of the value.
-|!is |For matching if the left hand side type is not an instanceof the value.
+|!is |For matching if the left hand side type is not an instance of the value.
|range |For matching if the left hand side is within a range of values defined
as numbers: `from..to`..
@@ -514,14 +481,14 @@ And the following logical operators can be used to group expressions:
The syntax for AND is:
-[source]
+[source,text]
----------------------------------------------------------
${leftValue} OP rightValue && ${leftValue} OP rightValue
----------------------------------------------------------
And the syntax for OR is:
-[source]
+[source,text]
---------------------------------------------------------
${leftValue} OP rightValue || ${leftValue} OP rightValue
---------------------------------------------------------
@@ -531,18 +498,18 @@ Some examples:
[source,java]
----
// exact equals match
-simple("${in.header.foo} == 'foo'")
+simple("${header.foo} == 'foo'")
// ignore case when comparing, so if the header has value FOO this will match
-simple("${in.header.foo} =~ 'foo'")
+simple("${header.foo} =~ 'foo'")
-// here Camel will type convert '100' into the type of in.header.bar and if it is an Integer '100' will also be converter to an Integer
-simple("${in.header.bar} == '100'")
+// here Camel will type convert '100' into the type of header.bar and if it is an Integer '100' will also be converter to an Integer
+simple("${header.bar} == '100'")
-simple("${in.header.bar} == 100")
+simple("${header.bar} == 100")
-// 100 will be converter to the type of in.header.bar so we can do > comparison
-simple("${in.header.bar} > 100")
+// 100 will be converter to the type of header.bar so we can do > comparison
+simple("${header.bar} > 100")
----
=== Comparing with different types
@@ -556,23 +523,23 @@ the bar value above is a String. Then you can flip the equation:
[source,java]
----
-simple("100 < ${in.header.bar}")
+simple("100 < ${header.bar}")
----
which then ensures the int type is used as 1st priority.
This may change in the future if the Camel team improves the binary
-comparison operations to prefer numeric types over String based. It's
+comparison operations to prefer numeric types to String based. It's
most often the String type which causes problem when comparing with
numbers.
[source,java]
----
// testing for null
-simple("${in.header.baz} == null")
+simple("${header.baz} == null")
// testing for not null
-simple("${in.header.baz} != null")
+simple("${header.baz} != null")
----
And a bit more advanced example where the right value is another
@@ -580,9 +547,9 @@ expression
[source,java]
----
-simple("${in.header.date} == ${date:now:yyyyMMdd}")
+simple("${header.date} == ${date:now:yyyyMMdd}")
-simple("${in.header.type} == ${bean:orderService?method=getOrderType}")
+simple("${header.type} == ${bean:orderService?method=getOrderType}")
----
And an example with contains, testing if the title contains the word
@@ -590,7 +557,7 @@ Camel
[source,java]
----
-simple("${in.header.title} contains 'Camel'")
+simple("${header.title} contains 'Camel'")
----
And an example with regex, testing if the number header is a 4 digit
@@ -598,7 +565,7 @@ value:
[source,java]
----
-simple("${in.header.number} regex '\\d{4}'")
+simple("${header.number} regex '\\d{4}'")
----
And finally an example if the header equals any of the values in the
@@ -608,14 +575,14 @@ into the type of the left hand side.
[source,java]
----
-simple("${in.header.type} in 'gold,silver'")
+simple("${header.type} in 'gold,silver'")
----
And for all the last 3 we also support the negate test using not:
[source,java]
----
-simple("${in.header.type} !in 'gold,silver'")
+simple("${header.type} !in 'gold,silver'")
----
And you can test if the type is a certain instance, eg for instance a
@@ -623,7 +590,7 @@ String
[source,java]
----
-simple("${in.header.type} is 'java.lang.String'")
+simple("${header.type} is 'java.lang.String'")
----
We have added a shorthand for all `java.lang` types so you can write it
@@ -631,7 +598,7 @@ as:
[source,java]
----
-simple("${in.header.type} is 'String'")
+simple("${header.type} is 'String'")
----
Ranges are also supported. The range interval requires numbers and both
@@ -640,17 +607,15 @@ between 100 and 199:
[source,java]
----
-simple("${in.header.number} range 100..199")
+simple("${header.number} range 100..199")
----
Notice we use `..` in the range without spaces. It is based on the same
syntax as Groovy.
-From *Camel 2.9* onwards the range value must be in single quotes
-
[source,java]
----
-simple("${in.header.number} range '100..199'")
+simple("${header.number} range '100..199'")
----
=== Using Spring XML
@@ -665,7 +630,7 @@ order:
----
<from uri="seda:orders">
<filter>
- <simple>${in.header.type} == 'widget'</simple>
+ <simple>${header.type} == 'widget'</simple>
<to uri="bean:orderService?method=handleWidget"/>
</filter>
</from>
@@ -680,25 +645,25 @@ For instance:
[source,java]
-----
-simple("${in.header.title} contains 'Camel' && ${in.header.type'} == 'gold'")
+simple("${header.title} contains 'Camel' && ${header.type'} == 'gold'")
-----
And of course the `||` is also supported. The sample would be:
[source,java]
-----
-simple("${in.header.title} contains 'Camel' || ${in.header.type'} == 'gold'")
+simple("${header.title} contains 'Camel' || ${header.type'} == 'gold'")
-----
== Samples
-In the Spring XML sample below we filter based on a header value:
+In the XML DSL sample below we filter based on a header value:
[source,xml]
--------------------------------------------
<from uri="seda:orders">
<filter>
- <simple>${in.header.foo}</simple>
+ <simple>${header.foo}</simple>
<to uri="mock:fooOrders"/>
</filter>
</from>
@@ -715,7 +680,7 @@ The same example in Java DSL:
[source,java]
----
from("seda:orders")
- .filter().simple("${in.header.foo}")
+ .filter().simple("${header.foo}")
.to("seda:fooOrders");
----
@@ -725,7 +690,7 @@ as:
[source,java]
----
from("direct:hello")
- .transform().simple("Hello ${in.header.user} how are you?")
+ .transform().simple("Hello ${header.user} how are you?")
.to("mock:reply");
----
@@ -814,14 +779,6 @@ You can nest functions, such as shown below:
</setHeader>
----
-== Referring to constants or enums
-
-Suppose you have an enum for customers
-
-And in a Content Based Router we can use
-the xref:simple-language.adoc[Simple] language to refer to this enum, to check
-the message which enum it matches.
-
== Using new lines or tabs in XML DSLs
It is easier to specify new lines or tabs in
@@ -884,19 +841,3 @@ eg to refer to a file on the classpath you can do:
.setHeader("myHeader").simple("resource:classpath:mysimple.txt")
----
-== Setting Spring beans to Exchange properties
-
-You can set a spring bean into an exchange property as shown below:
-
-[source,xml]
-----
-<bean id="myBeanId" class="my.package.MyCustomClass" />
-...
-<route>
- ...
- <setProperty name="monitoring.message">
- <simple>ref:myBeanId</simple>
- </setProperty>
- ...
-</route>
-----
diff --git a/core/camel-core-languages/src/main/docs/modules/languages/pages/tokenize-language.adoc b/core/camel-core-languages/src/main/docs/modules/languages/pages/tokenize-language.adoc
index f189b66..97f118c 100644
--- a/core/camel-core-languages/src/main/docs/modules/languages/pages/tokenize-language.adoc
+++ b/core/camel-core-languages/src/main/docs/modules/languages/pages/tokenize-language.adoc
@@ -10,8 +10,9 @@ include::{cq-version}@camel-quarkus:ROOT:partial$reference/languages/tokenize.ad
*Since Camel {since}*
The tokenizer language is a built-in language in camel-core, which is
-most often used only with the Splitter EIP to split
-a message using a token-based strategy. +
+most often used with the Splitter EIP to split
+a message using a token-based strategy.
+
The tokenizer language is intended to tokenize text documents using a
specified delimiter pattern. It can also be used to tokenize XML
documents with some limited capability. For a truly XML-aware
@@ -19,8 +20,6 @@ tokenization, the use of the XMLTokenizer
language is recommended as it offers a faster, more efficient
tokenization specifically for XML documents.
-For more details see xref:{eip-vc}:eips:split-eip.adoc[Split] EIP.
-
== Tokenize Options
// language options: START
@@ -44,3 +43,30 @@ The Tokenize language supports 11 options, which are listed below.
| trim | true | Boolean | Whether to trim the value to remove leading and trailing whitespaces and line breaks
|===
// language options: END
+
+
+== Example usage
+
+The following example shows how to take a request from the *direct:a* endpoint the split it into pieces using an Expression, then forward each piece to *direct:b*
+
+[source,xml]
+----
+<route>
+ <from uri="direct:a"/>
+ <split>
+ <tokenize token="\n"/>
+ <to uri="direct:b"/>
+ </split>
+</route>
+----
+
+And in Java DSL:
+
+[source,java]
+----
+from("direct:a")
+ .split(body().tokenize("\n"))
+ .to("direct:b");
+----
+
+For more examples see xref:{eip-vc}:eips:split-eip.adoc[Split] EIP.
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/FileLanguage.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/FileLanguage.java
index 0a35e79..83b535c 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/FileLanguage.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/FileLanguage.java
@@ -19,7 +19,7 @@ package org.apache.camel.language.simple;
import org.apache.camel.spi.annotations.Language;
/**
- *
+ * The Camel file language.
*/
@Language("file")
public class FileLanguage extends SimpleLanguage {
diff --git a/docs/components/modules/languages/pages/csimple-language.adoc b/docs/components/modules/languages/pages/csimple-language.adoc
index ed2e424..1c45316 100644
--- a/docs/components/modules/languages/pages/csimple-language.adoc
+++ b/docs/components/modules/languages/pages/csimple-language.adoc
@@ -20,13 +20,13 @@ The simple language is a dynamic expression language which is runtime parsed int
The csimple language is parsed into regular Java source code and compiled together with all the other source code,
or compiled once during bootstrap via the `camel-csimple-joor` module.
-The simple langauge is generally very lightweight and fast, however for some use-cases with dynamic method calls via OGNL paths,
+The simple language is generally very lightweight and fast, however for some use-cases with dynamic method calls via OGNL paths,
then the simple language does runtime introspection and reflection calls. This has an overhead on performance,
and was one of the reasons why csimple was created.
The csimple language requires to be typesafe and method calls via OGNL paths requires to know the type during parsing.
This means for csimple languages expressions you would need to provide the class type in the script,
-where as simple introspects this at runtime.
+whereas simple introspects this at runtime.
In other words the simple language is using _duck typing_ (if it looks like a duck, and quacks like a duck, then it is a duck)
and csimple is using Java type (typesafety). If there is a type error then simple will report this at runtime,
@@ -88,14 +88,14 @@ There are two ways to compile csimple
=== Using camel-csimple-maven-plugin
-The `camel-csimple-maven-plugin` Maven plugin is used for discoving all the csimple scripts from the source code, and then automatic generate source code in the `src/generated/java` folder, which then gets compiled together with all the other sources.
+The `camel-csimple-maven-plugin` Maven plugin is used for discovering all the csimple scripts from the source code, and then automatic generate source code in the `src/generated/java` folder, which then gets compiled together with all the other sources.
The maven plugin will do source code scanning of `.java` and `.xml` files (Java and XML DSL).
The scanner limits to detect certain code patterns, and it may miss discovering some csimple scripts if they are being used in unusual/rare ways.
The runtime compilation using `camel-csimple-joor` does not have this limitation.
-However the pros is that all of the csimple scripts will be compiled using the regular Java compiler and therefore everything
+The benefit is all the csimple scripts will be compiled using the regular Java compiler and therefore everything
is included out of the box as `.class` files in the application JAR file, and no additional dependencies is required at runtime.
To use `camel-csimple-maven-plugin` you need to add it to your `pom.xml` file as shown:
@@ -192,7 +192,7 @@ The CSimple language supports 2 options, which are listed below.
== Limitations
-Currently the csimple language does **not** support:
+Currently, the csimple language does **not** support:
- nested functions (aka functions inside functions)
- the _null safe_ operator (`?`).
@@ -211,7 +211,7 @@ For example the following scripts cannot compile:
== Auto imports
-The csimple language will automatic import from:
+The csimple language will automatically import from:
[source,java]
----
diff --git a/docs/components/modules/languages/pages/exchangeProperty-language.adoc b/docs/components/modules/languages/pages/exchangeProperty-language.adoc
index c97198b..5af83a6 100644
--- a/docs/components/modules/languages/pages/exchangeProperty-language.adoc
+++ b/docs/components/modules/languages/pages/exchangeProperty-language.adoc
@@ -28,13 +28,9 @@ The ExchangeProperty language supports 1 options, which are listed below.
|===
// language options: END
-== Example usage
+== Example
-The recipientList element of the Spring DSL can utilize a
-exchangeProperty expression like:
-
-In this case, the list of recipients are contained in the property
-'myProperty'.
+The `recipientList` EIP can utilize a exchangeProperty like:
[source,xml]
----
@@ -46,6 +42,9 @@ In this case, the list of recipients are contained in the property
</route>
----
+In this case, the list of recipients are contained in the property
+'myProperty'.
+
And the same example in Java DSL:
[source,java]
@@ -53,16 +52,6 @@ And the same example in Java DSL:
from("direct:a").recipientList(exchangeProperty("myProperty"));
----
-And with a slightly different syntax where you use the builder to the
-fullest (i.e. avoid using parameters but using stacked operations,
-notice that exchangeProperty is not a parameter but a stacked method
-call)
-
-[source,java]
-----
-from("direct:a").recipientList().exchangeProperty("myProperty");
-----
-
== Dependencies
The ExchangeProperty language is part of *camel-core*.
diff --git a/docs/components/modules/languages/pages/file-language.adoc b/docs/components/modules/languages/pages/file-language.adoc
index 6a5ce24..5724dfe 100644
--- a/docs/components/modules/languages/pages/file-language.adoc
+++ b/docs/components/modules/languages/pages/file-language.adoc
@@ -4,23 +4,25 @@
:page-source: core/camel-core-languages/src/main/docs/modules/languages/pages/file-language.adoc
:docTitle: File
:artifactId: camel-core-languages
-:description: File related capabilities for the Simle language
+:description: File related capabilities for the Simple language
:since: 1.1
:supportLevel: Stable
include::{cq-version}@camel-quarkus:ROOT:partial$reference/languages/file.adoc[opts=optional]
*Since Camel {since}*
-The file language is merged with
-xref:simple-language.adoc[Simple] language which means you can use all the file
-syntax directly within the simple language.
-
The File Expression Language is an extension to the
xref:simple-language.adoc[Simple] language, adding file related capabilities.
These capabilities are related to common use cases working with file
path and names. The goal is to allow expressions to be used with the
-File and FTP components for setting
-dynamic file patterns for both consumer and producer.
+
+xref:components::file-component.adoc[File] and xref:components::ftp-component.adoc[FTP]
+components for setting dynamic file patterns for both consumer and producer.
+
+NOTE: The file language is merged with
+xref:simple-language.adoc[Simple] language which means you can use all the file
+syntax directly within the simple language.
+
== File Language options
@@ -41,19 +43,13 @@ The File language supports 2 options, which are listed below.
This language is an *extension* to the xref:simple-language.adoc[Simple] language
so the xref:simple-language.adoc[Simple] syntax applies also. So the table below
-only lists the additional. +
- As opposed to xref:simple-language.adoc[Simple] language
-xref:file-language.adoc[File Language] also supports
-xref:constant-language.adoc[Constant] expressions so you can enter a fixed
-filename.
+only lists the additional file related functions.
All the file tokens use the same expression name as the method on the
`java.io.File` object, for instance `file:absolute` refers to the
`java.io.File.getAbsolute()` method. Notice that not all expressions are
supported by the current Exchange. For instance the xref:components::ftp-component.adoc[FTP]
-component supports some of the options, where as the
-File component supports all of them.
-
+component supports some options, whereas the File component supports all of them.
[width="100%",cols="10%,10%,10%,10%,10%,25%,25%",options="header",]
|===
@@ -65,7 +61,7 @@ below)
|file:name.ext |String |yes |no |yes |no |refers to the file extension only
|file:name.ext.single |String |yes |no |yes |no |refers to the file extension. If the file
-extension has mutiple dots, then this expression strips and only returns
+extension has multiple dots, then this expression strips and only returns
the last part.
|file:name.noext |String |yes |no |yes |no |refers to the file name with no extension (is relative to the starting
@@ -178,17 +174,16 @@ return as:
== Samples
-You can enter a fixed xref:constant-language.adoc[Constant] expression such as
-`myfile.txt`:
+You can enter a fixed file name such as `myfile.txt`:
[source]
----
fileName="myfile.txt"
----
-Lets assume we use the file consumer to read files and want to move the
-read files to backup folder with the current date as a sub folder. This
-can be archieved using an expression like:
+Let's assume we use the file consumer to read files and want to move the
+read files to back up folder with the current date as a sub folder. This
+can be done using an expression like:
[source]
----
@@ -196,7 +191,7 @@ fileName="backup/${date:now:yyyyMMdd}/${file:name.noext}.bak"
----
relative folder names are also supported so suppose the backup folder
-should be a sibling folder then you can append .. as:
+should be a sibling folder then you can append `..` as shown:
[source]
----
@@ -213,8 +208,8 @@ expression:
fileName="../backup/${date:now:yyyyMMdd}/type-${in.header.type}/backup-of-${file:name.noext}.bak"
----
-If you have a custom Date you want to use in the expression then Camel
-supports retrieving dates from the message header.
+If you have a custom date you want to use in the expression then Camel
+supports retrieving dates from the message header:
[source]
----
@@ -229,74 +224,11 @@ that generates some String output (or convertible to String) to be used:
fileName="uniquefile-${bean:myguidgenerator.generateid}.txt"
----
-And of course all this can be combined in one expression where you can
+Of course all this can be combined in one expression where you can
use the xref:file-language.adoc[File Language], xref:file-language.adoc[Simple]
and the xref:components::bean-component.adoc[Bean] language in one combined expression. This
is pretty powerful for those common file path patterns.
-== Using Spring PropertyPlaceholderConfigurer together with the File component
-
-In Camel you can use the xref:file-language.adoc[File Language] directly
-from the xref:simple-language.adoc[Simple] language which makes a
-Content Based Router easier to do in
-Spring XML, where we can route based on file extensions as shown below:
-
-[source,xml]
-----
-<from uri="file://input/orders"/>
- <choice>
- <when>
- <simple>${file:ext} == 'txt'</simple>
- <to uri="bean:orderService?method=handleTextFiles"/>
- </when>
- <when>
- <simple>${file:ext} == 'xml'</simple>
- <to uri="bean:orderService?method=handleXmlFiles"/>
- </when>
- <otherwise>
- <to uri="bean:orderService?method=handleOtherFiles"/>
- </otherwise>
- </choice>
-----
-
-If you use the `fileName` option on the File endpoint
-to set a dynamic filename using the xref:file-language.adoc[File Language] then make sure you +
- use the alternative syntax to avoid
-clashing with Springs `PropertyPlaceholderConfigurer`.
-
-*bundle-context.xml*
-
-[source,xml]
-----
-<bean id="propertyPlaceholder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
- <property name="location" value="classpath:bundle-context.cfg" />
-</bean>
-
-<bean id="sampleRoute" class="SampleRoute">
- <property name="fromEndpoint" value="${fromEndpoint}" />
- <property name="toEndpoint" value="${toEndpoint}" />
-</bean>
-----
-
-*bundle-context.cfg*
-
-[source]
-----
-fromEndpoint=activemq:queue:test
-toEndpoint=file://fileRoute/out?fileName=test-$simple{date:now:yyyyMMdd}.txt
-----
-
-Notice how we use the $simple\{ } syntax in the `toEndpoint` above. +
- If you don't do this, there is a clash and Spring will throw an
-exception like
-
-[source,java]
-----------------------------------------------------------------------------------------------------
-org.springframework.beans.factory.BeanDefinitionStoreException:
-Invalid bean definition with name 'sampleRoute' defined in class path resource [bundle-context.xml]:
-Could not resolve placeholder 'date:now:yyyyMMdd'
-----------------------------------------------------------------------------------------------------
-
== Dependencies
The File language is part of *camel-core*.
diff --git a/docs/components/modules/languages/pages/header-language.adoc b/docs/components/modules/languages/pages/header-language.adoc
index 679b2c3..bfdcfb5 100644
--- a/docs/components/modules/languages/pages/header-language.adoc
+++ b/docs/components/modules/languages/pages/header-language.adoc
@@ -30,19 +30,16 @@ The Header language supports 1 options, which are listed below.
== Example usage
-== Example usage
-
-The recipientList element of the Spring DSL can utilize a header
-expression like:
+The `recipientList` EIP can utilize a header:
[source,xml]
----
- <route>
- <from uri="direct:a" />
- <recipientList>
- <header>myHeader</header>
- </recipientList>
- </route>
+<route>
+ <from uri="direct:a" />
+ <recipientList>
+ <header>myHeader</header>
+ </recipientList>
+</route>
----
In this case, the list of recipients are contained in the header
@@ -55,15 +52,6 @@ And the same example in Java DSL:
from("direct:a").recipientList(header("myHeader"));
----
-And with a slightly different syntax where you use the builder to the
-fullest (i.e. avoid using parameters but using stacked operations,
-notice that header is not a parameter but a stacked method call)
-
-[source,java]
-----
-from("direct:a").recipientList().header("myHeader");
-----
-
== Dependencies
The Header language is part of *camel-core*.
diff --git a/docs/components/modules/languages/pages/ref-language.adoc b/docs/components/modules/languages/pages/ref-language.adoc
index 56cf293..a6c362a 100644
--- a/docs/components/modules/languages/pages/ref-language.adoc
+++ b/docs/components/modules/languages/pages/ref-language.adoc
@@ -12,7 +12,7 @@ include::{cq-version}@camel-quarkus:ROOT:partial$reference/languages/ref.adoc[op
*Since Camel {since}*
The Ref Expression Language is really just a way to lookup a custom
-Expression or Predicate from the Registry.
+`Expression` or `Predicate` from the xref:latest@manual:ROOT:registry.adoc[Registry].
This is particular useable in XML DSLs.
@@ -32,7 +32,7 @@ The Ref language supports 1 options, which are listed below.
== Example usage
-The Splitter in XML DSL can utilize a custom
+The Splitter EIP in XML DSL can utilize a custom
expression using `<ref>` like:
[source,xml]
@@ -48,10 +48,10 @@ expression using `<ref>` like:
</route>
----
-in this case, the Message coming from the seda:a
-Endpoint will be splitted using a custom
-Expression which has the id `myExpression` in the
-Registry.
+in this case, the message coming from the seda:a
+endpoint will be splitted using a custom
+`Expression` which has the id `myExpression` in the
+xref:latest@manual:ROOT:registry.adoc[Registry].
And the same example using Java DSL:
diff --git a/docs/components/modules/languages/pages/simple-language.adoc b/docs/components/modules/languages/pages/simple-language.adoc
index d638117..532893a 100644
--- a/docs/components/modules/languages/pages/simple-language.adoc
+++ b/docs/components/modules/languages/pages/simple-language.adoc
@@ -14,14 +14,13 @@ include::{cq-version}@camel-quarkus:ROOT:partial$reference/languages/simple.adoc
The Simple Expression Language was a really simple language when it was
created, but has since grown more powerful. It is primarily intended for
being a very small and simple language for evaluating
-Expressions and Predicates
-without requiring any new dependencies or knowledge of
-xref:xpath-language.adoc[XPath]; so it is ideal for testing in camel-core. The
-idea was to cover 95% of the common use cases when you need a little bit
-of expression based script in your Camel routes.
+`Expression` or `Predicate` without requiring any new dependencies
+or knowledge of other scripting languages such as Groovy.
-However for much more complex use cases you are generally recommended to
-choose a more expressive and powerful language such as:
+The simple langauge is designed with intend to cover almost all of the common use cases
+when little need for scripting in your Camel routes.
+
+However, for much more complex use cases then a more powerful language is recommended such as:
* xref:groovy-language.adoc[Groovy]
* xref:mvel-language.adoc[MVEL]
@@ -82,9 +81,9 @@ OGNL expression.
|exchangeId |String |the exchange id
-|id |String |the input message id
+|id |String |the message id
-|messageTimestamp |String |the input message timestamp (millis since epoc) that this message originates from.
+|messageTimestamp |String |the message timestamp (millis since epoc) that this message originates from.
Some systems like JMS, Kafka, AWS have a timestamp on the event/message, that Camel received. This method returns
the timestamp, if a timestamp exists.
The message timestamp and exchange created are not the same. An exchange always have a created timestamp which is the
@@ -92,13 +91,9 @@ local timestamp when Camel created the exchange. The message timestamp is only a
when the consumer is able to extract the timestamp from the source event.
If the message has no timestamp then 0 is returned.
-|body |Object |the input body
-
-|in.body |Object |*deprecated* the input body
+|body |Object |the body
-|body.*OGNL* |Object |the input body invoked using a Camel OGNL expression.
-
-|in.body.*OGNL* |Object |*deprecated* the input body invoked using a Camel OGNL expression.
+|body.*OGNL* |Object |the body invoked using a Camel OGNL expression.
|bodyAs(_type_) |Type |Converts the body to the given type determined by its
classname. The converted body can be null.
@@ -115,54 +110,26 @@ classname, and expects the body to be not null.
|mandatoryBodyAs(_type_).*OGNL* |Object |Converts the body to the given type determined by its
classname and then invoke methods using a Camel OGNL expression.
-|header.foo |Object |refer to the input foo header
-
-|header:foo |Object |refer to the input foo header
-
-|header[foo] |Object |refer to the input foo header
-
-|headers.foo |Object |refer to the input foo header
-
-|headers:foo |Object |refer to the input foo header
-
-|headers[foo] |Object |refer to the input foo header
+|header.foo |Object |refer to the foo header
-|in.header.foo |Object |*deprecated* refer to the input foo header
+|header[foo] |Object |refer to the foo header
-|in.header:foo |Object |*deprecated* refer to the input foo header
+|headers.foo |Object |refer to the foo header
-|in.header[foo] |Object |*deprecated* refer to the input foo header
+|headers:foo |Object |refer to the foo header
-|in.headers.foo |Object |*deprecated* refer to the input foo header
+|headers[foo] |Object |refer to the foo header
-|in.headers:foo |Object |*deprecated* refer to the input foo header
-
-|in.headers[foo] |Object |*deprecated* refer to the input foo header
-
-|header.foo[bar] |Object |regard input foo header as a map and perform lookup on the
-map with bar as key
-
-|in.header.foo[bar] |Object |*deprecated* regard input foo header as a map and perform lookup on the
+|header.foo[bar] |Object |regard foo header as a map and perform lookup on the
map with bar as key
-|in.headers.foo[bar] |Object |*deprecated* regard input foo header as a map and perform lookup on the
-map with bar as key
-
-|header.foo.*OGNL* |Object |refer to the input foo header and invoke its value using a
-Camel OGNL expression.
-
-|in.header.foo.*OGNL* |Object |*deprecated* refer to the input foo header and invoke its value using a
-Camel OGNL expression.
-
-|in.headers.foo.*OGNL* |Object |*deprecated* refer to the input foo header and invoke its value using a
+|header.foo.*OGNL* |Object |refer to the foo header and invoke its value using a
Camel OGNL expression.
|headerAs(_key_,_type_) |Type |converts the header to the given type determined by its
classname
-|headers |Map |refer to the input headers
-
-|in.headers |Map |*deprecated* refer to the input headers
+|headers |Map |refer to the headers
|exchangeProperty.foo |Object |refer to the foo property on the exchange
@@ -229,7 +196,7 @@ logging purpose.
the given id.
|type:name.field |Object |To refer to a type or field by its FQN name. To refer to a
-field you can append .FIELD_NAME. For example you can refer to the
+field you can append .FIELD_NAME. For example, you can refer to the
constant field from Exchange as: `org.apache.camel.Exchange.FILE_NAME`
|null |null |represents a *null*
@@ -255,7 +222,7 @@ been routed. This is similar to the route stack-trace message history
the error handler logs in case of an unhandled exception.
|messageHistory(false) |String |As messageHistory but without the exchange details (only
-includes the route strack-trace). This can be used if you do not want to
+includes the route stack-trace). This can be used if you do not want to
log sensitive data from the message itself.
|=======================================================================
@@ -403,13 +370,13 @@ ${leftValue} OP rightValue
--------------------------
Where the `rightValue` can be a String literal enclosed in `' '`,
-`null`, a constant value or another expression enclosed in $\{ }.
+`null`, a constant value or another expression enclosed in `$\{ }`.
IMPORTANT: There *must* be spaces around the operator.
Camel will automatically type convert the rightValue type to the
-leftValue type, so it is able to eg. convert a string into a numeric so
-you can use > comparison for numeric values.
+leftValue type, so it is able to eg. convert a string into a numeric, so
+you can use `>` comparison for numeric values.
The following operators are supported:
@@ -455,9 +422,9 @@ is a set of four values with an empty value and then the three medals.
by comma. If you want to include an empty value, then it must be defined using double comma, eg ',,bronze,silver,gold', which
is a set of four values with an empty value and then the three medals.
-|is |For matching if the left hand side type is an instanceof the value.
+|is |For matching if the left hand side type is an instance of the value.
-|!is |For matching if the left hand side type is not an instanceof the value.
+|!is |For matching if the left hand side type is not an instance of the value.
|range |For matching if the left hand side is within a range of values defined
as numbers: `from..to`..
@@ -516,14 +483,14 @@ And the following logical operators can be used to group expressions:
The syntax for AND is:
-[source]
+[source,text]
----------------------------------------------------------
${leftValue} OP rightValue && ${leftValue} OP rightValue
----------------------------------------------------------
And the syntax for OR is:
-[source]
+[source,text]
---------------------------------------------------------
${leftValue} OP rightValue || ${leftValue} OP rightValue
---------------------------------------------------------
@@ -533,18 +500,18 @@ Some examples:
[source,java]
----
// exact equals match
-simple("${in.header.foo} == 'foo'")
+simple("${header.foo} == 'foo'")
// ignore case when comparing, so if the header has value FOO this will match
-simple("${in.header.foo} =~ 'foo'")
+simple("${header.foo} =~ 'foo'")
-// here Camel will type convert '100' into the type of in.header.bar and if it is an Integer '100' will also be converter to an Integer
-simple("${in.header.bar} == '100'")
+// here Camel will type convert '100' into the type of header.bar and if it is an Integer '100' will also be converter to an Integer
+simple("${header.bar} == '100'")
-simple("${in.header.bar} == 100")
+simple("${header.bar} == 100")
-// 100 will be converter to the type of in.header.bar so we can do > comparison
-simple("${in.header.bar} > 100")
+// 100 will be converter to the type of header.bar so we can do > comparison
+simple("${header.bar} > 100")
----
=== Comparing with different types
@@ -558,23 +525,23 @@ the bar value above is a String. Then you can flip the equation:
[source,java]
----
-simple("100 < ${in.header.bar}")
+simple("100 < ${header.bar}")
----
which then ensures the int type is used as 1st priority.
This may change in the future if the Camel team improves the binary
-comparison operations to prefer numeric types over String based. It's
+comparison operations to prefer numeric types to String based. It's
most often the String type which causes problem when comparing with
numbers.
[source,java]
----
// testing for null
-simple("${in.header.baz} == null")
+simple("${header.baz} == null")
// testing for not null
-simple("${in.header.baz} != null")
+simple("${header.baz} != null")
----
And a bit more advanced example where the right value is another
@@ -582,9 +549,9 @@ expression
[source,java]
----
-simple("${in.header.date} == ${date:now:yyyyMMdd}")
+simple("${header.date} == ${date:now:yyyyMMdd}")
-simple("${in.header.type} == ${bean:orderService?method=getOrderType}")
+simple("${header.type} == ${bean:orderService?method=getOrderType}")
----
And an example with contains, testing if the title contains the word
@@ -592,7 +559,7 @@ Camel
[source,java]
----
-simple("${in.header.title} contains 'Camel'")
+simple("${header.title} contains 'Camel'")
----
And an example with regex, testing if the number header is a 4 digit
@@ -600,7 +567,7 @@ value:
[source,java]
----
-simple("${in.header.number} regex '\\d{4}'")
+simple("${header.number} regex '\\d{4}'")
----
And finally an example if the header equals any of the values in the
@@ -610,14 +577,14 @@ into the type of the left hand side.
[source,java]
----
-simple("${in.header.type} in 'gold,silver'")
+simple("${header.type} in 'gold,silver'")
----
And for all the last 3 we also support the negate test using not:
[source,java]
----
-simple("${in.header.type} !in 'gold,silver'")
+simple("${header.type} !in 'gold,silver'")
----
And you can test if the type is a certain instance, eg for instance a
@@ -625,7 +592,7 @@ String
[source,java]
----
-simple("${in.header.type} is 'java.lang.String'")
+simple("${header.type} is 'java.lang.String'")
----
We have added a shorthand for all `java.lang` types so you can write it
@@ -633,7 +600,7 @@ as:
[source,java]
----
-simple("${in.header.type} is 'String'")
+simple("${header.type} is 'String'")
----
Ranges are also supported. The range interval requires numbers and both
@@ -642,17 +609,15 @@ between 100 and 199:
[source,java]
----
-simple("${in.header.number} range 100..199")
+simple("${header.number} range 100..199")
----
Notice we use `..` in the range without spaces. It is based on the same
syntax as Groovy.
-From *Camel 2.9* onwards the range value must be in single quotes
-
[source,java]
----
-simple("${in.header.number} range '100..199'")
+simple("${header.number} range '100..199'")
----
=== Using Spring XML
@@ -667,7 +632,7 @@ order:
----
<from uri="seda:orders">
<filter>
- <simple>${in.header.type} == 'widget'</simple>
+ <simple>${header.type} == 'widget'</simple>
<to uri="bean:orderService?method=handleWidget"/>
</filter>
</from>
@@ -682,25 +647,25 @@ For instance:
[source,java]
-----
-simple("${in.header.title} contains 'Camel' && ${in.header.type'} == 'gold'")
+simple("${header.title} contains 'Camel' && ${header.type'} == 'gold'")
-----
And of course the `||` is also supported. The sample would be:
[source,java]
-----
-simple("${in.header.title} contains 'Camel' || ${in.header.type'} == 'gold'")
+simple("${header.title} contains 'Camel' || ${header.type'} == 'gold'")
-----
== Samples
-In the Spring XML sample below we filter based on a header value:
+In the XML DSL sample below we filter based on a header value:
[source,xml]
--------------------------------------------
<from uri="seda:orders">
<filter>
- <simple>${in.header.foo}</simple>
+ <simple>${header.foo}</simple>
<to uri="mock:fooOrders"/>
</filter>
</from>
@@ -717,7 +682,7 @@ The same example in Java DSL:
[source,java]
----
from("seda:orders")
- .filter().simple("${in.header.foo}")
+ .filter().simple("${header.foo}")
.to("seda:fooOrders");
----
@@ -727,7 +692,7 @@ as:
[source,java]
----
from("direct:hello")
- .transform().simple("Hello ${in.header.user} how are you?")
+ .transform().simple("Hello ${header.user} how are you?")
.to("mock:reply");
----
@@ -816,14 +781,6 @@ You can nest functions, such as shown below:
</setHeader>
----
-== Referring to constants or enums
-
-Suppose you have an enum for customers
-
-And in a Content Based Router we can use
-the xref:simple-language.adoc[Simple] language to refer to this enum, to check
-the message which enum it matches.
-
== Using new lines or tabs in XML DSLs
It is easier to specify new lines or tabs in
@@ -886,19 +843,3 @@ eg to refer to a file on the classpath you can do:
.setHeader("myHeader").simple("resource:classpath:mysimple.txt")
----
-== Setting Spring beans to Exchange properties
-
-You can set a spring bean into an exchange property as shown below:
-
-[source,xml]
-----
-<bean id="myBeanId" class="my.package.MyCustomClass" />
-...
-<route>
- ...
- <setProperty name="monitoring.message">
- <simple>ref:myBeanId</simple>
- </setProperty>
- ...
-</route>
-----
diff --git a/docs/components/modules/languages/pages/tokenize-language.adoc b/docs/components/modules/languages/pages/tokenize-language.adoc
index bc7bede..0e881b7 100644
--- a/docs/components/modules/languages/pages/tokenize-language.adoc
+++ b/docs/components/modules/languages/pages/tokenize-language.adoc
@@ -12,8 +12,9 @@ include::{cq-version}@camel-quarkus:ROOT:partial$reference/languages/tokenize.ad
*Since Camel {since}*
The tokenizer language is a built-in language in camel-core, which is
-most often used only with the Splitter EIP to split
-a message using a token-based strategy. +
+most often used with the Splitter EIP to split
+a message using a token-based strategy.
+
The tokenizer language is intended to tokenize text documents using a
specified delimiter pattern. It can also be used to tokenize XML
documents with some limited capability. For a truly XML-aware
@@ -21,8 +22,6 @@ tokenization, the use of the XMLTokenizer
language is recommended as it offers a faster, more efficient
tokenization specifically for XML documents.
-For more details see xref:{eip-vc}:eips:split-eip.adoc[Split] EIP.
-
== Tokenize Options
// language options: START
@@ -46,3 +45,30 @@ The Tokenize language supports 11 options, which are listed below.
| trim | true | Boolean | Whether to trim the value to remove leading and trailing whitespaces and line breaks
|===
// language options: END
+
+
+== Example usage
+
+The following example shows how to take a request from the *direct:a* endpoint the split it into pieces using an Expression, then forward each piece to *direct:b*
+
+[source,xml]
+----
+<route>
+ <from uri="direct:a"/>
+ <split>
+ <tokenize token="\n"/>
+ <to uri="direct:b"/>
+ </split>
+</route>
+----
+
+And in Java DSL:
+
+[source,java]
+----
+from("direct:a")
+ .split(body().tokenize("\n"))
+ .to("direct:b");
+----
+
+For more examples see xref:{eip-vc}:eips:split-eip.adoc[Split] EIP.
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageLanguageMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageLanguageMojo.java
index f81ff99..e3abe72 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageLanguageMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageLanguageMojo.java
@@ -312,7 +312,7 @@ public class PackageLanguageMojo extends AbstractGeneratorMojo {
private static String asDescription(String name, String description) {
// special for some languages
if ("file".equals(name)) {
- return "File related capabilities for the Simle language";
+ return "File related capabilities for the Simple language";
}
return description;
}