This is an automated email from the ASF dual-hosted git repository. orpiske pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit 45bd00cd868d7ffa5dbd792f1915f7a8d9f44b02 Author: Otavio Rodolfo Piske <[email protected]> AuthorDate: Tue Feb 20 17:41:16 2024 +0100 CAMEL-20410: documentation fixes for camel-groovy - Fixed samples - Fixed grammar and typos - Fixed punctuation - Added and/or fixed links --- .../src/main/docs/groovy-language.adoc | 30 +++++++++++++--------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/components/camel-groovy/src/main/docs/groovy-language.adoc b/components/camel-groovy/src/main/docs/groovy-language.adoc index 82250fd595d..26bfbc82f7b 100644 --- a/components/camel-groovy/src/main/docs/groovy-language.adoc +++ b/components/camel-groovy/src/main/docs/groovy-language.adoc @@ -30,19 +30,23 @@ include::partial$language-options.adoc[] == Examples -In the example below we use a groovy script as predicate in the message filter, -to determine if any line items is over $100: +In the example below, we use a groovy script as predicate in the message filter, +to determine if any line items are over $100: +[tabs] +==== + +Java:: ++ [source,java] ------------------------------------------------------------------------------------------------ -// lets route if a line item is over $100 from("queue:foo") .filter(groovy("request.lineItems.any { i -> i.value > 100 }")) .to("queue:bar") ------------------------------------------------------------------------------------------------ -And in XML DSL: - +XML DSL:: ++ [source,xml] ---- <route> @@ -54,6 +58,8 @@ And in XML DSL: </route> ---- +==== + == Groovy Context Camel will provide exchange information in the Groovy context (just @@ -84,9 +90,9 @@ a `Map`). The `Exchange` is transferred as: == How to get the result from multiple statements script As the Groovy script engine evaluate method just return a `Null` if it runs a -multiple statements script. Camel now look up the value of script result -by using the key of "result" from the value set. If you have multiple -statements script, you need to make sure you set the value of result +multiple statements script. Camel now looks up the value of script result +by using the key of `result` from the value set. If you have multiple +statements scripts, you need to make sure you set the value of result variable as the script return value. [source,text] @@ -125,9 +131,9 @@ custom static imports), instead of the default one. == Loading script from external resource You can externalize the script and have Camel load it from a resource -such as `"classpath:"`, `"file:"`, or `"http:"`. + - This is done using the following syntax: `"resource:scheme:location"`, -eg to refer to a file on the classpath you can do: +such as `"classpath:"`, `"file:"`, or `"http:"`. +This is done using the following syntax: `"resource:scheme:location"`, +e.g., to refer to a file on the classpath you can do: [source,java] ------------------------------------------------------------------- @@ -136,7 +142,7 @@ eg to refer to a file on the classpath you can do: == Dependencies -To use scripting languages in your camel routes you need to add a +To use scripting languages in your camel routes, you need to add a dependency on *camel-groovy*. If you use Maven you could just add the following to your `pom.xml`,
