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

commit 70ad3f4bb6ad73fa9e285b944dd4f8b27d41e7b7
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Nov 6 09:38:22 2023 +0100

    CAMEL-20066: camel-language - Missing examples in docs
---
 .../src/main/docs/language-component.adoc          | 46 ++++++++++++++++------
 1 file changed, 34 insertions(+), 12 deletions(-)

diff --git a/components/camel-language/src/main/docs/language-component.adoc 
b/components/camel-language/src/main/docs/language-component.adoc
index fc086315902..743fd3db516 100644
--- a/components/camel-language/src/main/docs/language-component.adoc
+++ b/components/camel-language/src/main/docs/language-component.adoc
@@ -15,17 +15,17 @@
 
 *{component-header}*
 
-The Language component allows you to send Exchange
+The Language component allows you to send `Exchange`
 to an endpoint which executes a script by any of the supported
-Languages in Camel. +
- By having a component to execute language scripts, it allows more
+Languages in Camel.
+
+By having a component to execute language scripts, it allows more
 dynamic routing capabilities. For example by using the
 Routing Slip or xref:eips:dynamicRouter-eip.adoc[Dynamic
 Router] EIPs you can send messages to `language` endpoints where the
 script is dynamic defined as well.
 
-This component is provided out of the box in `camel-core` and hence no
-additional JARs is needed. You only have to include additional Camel
+You only have to include additional Camel
 components if the language of choice mandates it, such as using
 xref:languages:groovy-language.adoc[Groovy] or 
xref:languages:groovy-language.adoc[JavaScript] languages.
 
@@ -62,8 +62,8 @@ include::partial$component-endpoint-headers.adoc[]
 
 == Examples
 
-For example, you can use the xref:languages:simple-language.adoc[Simple] 
language to
-Message Translator a message:
+For example, you can use the xref:languages:simple-language.adoc[Simple] 
language as
+xref:eips:message-translator.adoc[Message Translator] EIP:
 
 [source,java]
 ----
@@ -103,16 +103,38 @@ assertEquals("Hello World", out);
 
 You can specify a resource uri for a script to load in either the
 endpoint uri, or in the `Exchange.LANGUAGE_SCRIPT` header.
-The uri must start with one of the following schemes: file:, classpath:, or 
http:
+The uri must start with one of the following schemes: `file:`, `classpath:`, 
or `http:`
+
+[source,java]
+----
+from("direct:start")
+        // load the script from the classpath
+        
.to("language:simple:resource:classpath:org/apache/camel/component/language/mysimplescript.txt")
+        .to("mock:result");
+----
 
 By default, the script is loaded once and cached. However, you can disable
 the `contentCache` option and have the script loaded on each
-evaluation. For example if the file myscript.txt is changed on disk, then the
+evaluation. For example if the file _myscript.txt_ is changed on disk, then the
 updated script is used:
 
-You can refer to the resource similar to the
-other xref:language-component.adoc[Language]s in Camel by prefixing with
-`"resource:"` as shown below:
+[source,java]
+----
+from("direct:start")
+        // the script will be loaded on each message, as we disabled cache
+        .to("language:simple:myscript.txt?contentCache=false")
+        .to("mock:result");
+----
+
+You can also refer to the script as a resource similar to how all the
+other xref:language-component.adoc[Language]s in Camel functions, by prefixing 
with
+`resource:` as shown below:
 
+[source,java]
+----
+from("direct:start")
+    
.to("language:constant:resource:classpath:org/apache/camel/component/language/hello.txt")
+    .to("mock:result");
+----
 
 include::spring-boot:partial$starter.adoc[]

Reply via email to