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 2023/10/23 15:01:24 UTC
[camel] branch camel-4.0.x updated: CAMEL-20029: camel-language - Missing examples in docs
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-4.0.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.0.x by this push:
new 8aa630f8694 CAMEL-20029: camel-language - Missing examples in docs
8aa630f8694 is described below
commit 8aa630f86943b34215047489079fb9352448236d
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Oct 23 17:00:36 2023 +0200
CAMEL-20029: camel-language - Missing examples in docs
---
.../src/main/docs/language-component.adoc | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/components/camel-language/src/main/docs/language-component.adoc b/components/camel-language/src/main/docs/language-component.adoc
index 781a5b7c2c5..fc086315902 100644
--- a/components/camel-language/src/main/docs/language-component.adoc
+++ b/components/camel-language/src/main/docs/language-component.adoc
@@ -65,11 +65,29 @@ include::partial$component-endpoint-headers.adoc[]
For example, you can use the xref:languages:simple-language.adoc[Simple] language to
Message Translator a message:
+[source,java]
+----
+from("direct:hello")
+ .to("language:simple:Hello ${body}")
+----
+
In case you want to convert the message body type you can do this as
-well:
+well (however it is better to use xref:eips:convertBodyTo-eip.adoc[Convert Body To]):
+
+[source,java]
+----
+from("direct:toString")
+ .to("language:simple:${bodyAs(String.class)}")
+----
You can also use the xref:languages:groovy-language.adoc[Groovy] language, such as this
-example where the input message will by multiplied with 2:
+example where the input message will be multiplied with 2:
+
+[source,groovy]
+----
+from("direct:double")
+ .to("language:groovy:${body} * 2}")
+----
You can also provide the script as a header as shown below. Here we use
xref:languages:xpath-language.adoc[XPath] language to extract the text from the `<foo>`