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 2020/10/16 19:35:37 UTC

[camel] 10/10: CAMEL-15697: camel-joor - Camel expression langauge using jOOR runtime java compiled.

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

commit c0ac6c0139cc7fe4f54d3b8944c29bb3c187f80b
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Oct 16 21:34:31 2020 +0200

    CAMEL-15697: camel-joor - Camel expression langauge using jOOR runtime java compiled.
---
 .../apache/camel/catalog/docs/joor-language.adoc   | 46 +++++++++++++++++++---
 .../camel-joor/src/main/docs/joor-language.adoc    | 46 +++++++++++++++++++---
 .../modules/languages/pages/joor-language.adoc     | 46 +++++++++++++++++++---
 3 files changed, 123 insertions(+), 15 deletions(-)

diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/joor-language.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/joor-language.adoc
index 3703f2c..0088364 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/joor-language.adoc
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/joor-language.adoc
@@ -34,9 +34,9 @@ The jOOR language supports 4 options, which are listed below.
 |===
 // language options: END
 
-=== Variables
+== Variables
 
-The jOOR language allows the following variables to be used in the script
+The jOOR language allows the following variables to be used in the script:
 
 [width="100%",cols="2,1m,7",options="header"]
 |===
@@ -47,7 +47,7 @@ The jOOR language allows the following variables to be used in the script
 | body | Object | The message body
 |===
 
-=== Sample
+== Sample
 
 For example to transform the message using jOOR language to upper case
 
@@ -70,7 +70,7 @@ And in XML DSL:
 </route>
 ----
 
-=== Multi statements
+== Multi statements
 
 It is possible to include multiple statements, for example where we in the first statement gets the `user` header.
 And then in the 2nd statement we return a value whether the user is `null` or not.
@@ -91,8 +91,44 @@ from("seda:orders")
   .to("seda:user");
 ----
 
-=== Limitations
+== Hot re-load
 
+You can turn of pre compilation for the jOOR language and then Camel will recompile the script for each message.
+You can externalize the code into a resource file, which will be reloaded on each message as shown:
+
+[source,java]
+----
+JoorLanguage joor = (JoorLanguage) context.resolveLanguage("joor");
+joor.setPreCompile(false);
+
+from("jms:incoming")
+    .transform().joor("resource:file:src/main/resources/orders.joor")
+    .to("jms:orders");
+----
+
+Here the jOOR script is externalized into the file `src/main/resources/orders.joor` which allows you to edit this source
+file while running the Camel application and try the changes with hot-reloading.
+
+In XML DSL its a little bit easier as you can turn off pre-compilation in the `<joor>` XML element:
+
+[source,xml]
+----
+<route>
+    <from uri="jms:incoming"/>
+    <transform>
+      <joor preCompile="false">resource:file:src/main/resources/orders.joor</joor>
+    </transform>
+    <to uri="jms:orders"/>
+</route>
+----
+
+== Limitations
+
+The jOOR Camel language is only supported as a block of Java code that gets compiled into a Java class with a single method.
+The code that you can write is therefore limited to a number of Java statements.
+
+The supported runtime is intended for Java standalone, Spring Boot, Camel Quarkus and other microservices runtimes.
+It is not supported in OSGi, Camel Karaf or any kind of Java Application Server runtime.
 
 == Dependencies
 
diff --git a/components/camel-joor/src/main/docs/joor-language.adoc b/components/camel-joor/src/main/docs/joor-language.adoc
index 3703f2c..0088364 100644
--- a/components/camel-joor/src/main/docs/joor-language.adoc
+++ b/components/camel-joor/src/main/docs/joor-language.adoc
@@ -34,9 +34,9 @@ The jOOR language supports 4 options, which are listed below.
 |===
 // language options: END
 
-=== Variables
+== Variables
 
-The jOOR language allows the following variables to be used in the script
+The jOOR language allows the following variables to be used in the script:
 
 [width="100%",cols="2,1m,7",options="header"]
 |===
@@ -47,7 +47,7 @@ The jOOR language allows the following variables to be used in the script
 | body | Object | The message body
 |===
 
-=== Sample
+== Sample
 
 For example to transform the message using jOOR language to upper case
 
@@ -70,7 +70,7 @@ And in XML DSL:
 </route>
 ----
 
-=== Multi statements
+== Multi statements
 
 It is possible to include multiple statements, for example where we in the first statement gets the `user` header.
 And then in the 2nd statement we return a value whether the user is `null` or not.
@@ -91,8 +91,44 @@ from("seda:orders")
   .to("seda:user");
 ----
 
-=== Limitations
+== Hot re-load
 
+You can turn of pre compilation for the jOOR language and then Camel will recompile the script for each message.
+You can externalize the code into a resource file, which will be reloaded on each message as shown:
+
+[source,java]
+----
+JoorLanguage joor = (JoorLanguage) context.resolveLanguage("joor");
+joor.setPreCompile(false);
+
+from("jms:incoming")
+    .transform().joor("resource:file:src/main/resources/orders.joor")
+    .to("jms:orders");
+----
+
+Here the jOOR script is externalized into the file `src/main/resources/orders.joor` which allows you to edit this source
+file while running the Camel application and try the changes with hot-reloading.
+
+In XML DSL its a little bit easier as you can turn off pre-compilation in the `<joor>` XML element:
+
+[source,xml]
+----
+<route>
+    <from uri="jms:incoming"/>
+    <transform>
+      <joor preCompile="false">resource:file:src/main/resources/orders.joor</joor>
+    </transform>
+    <to uri="jms:orders"/>
+</route>
+----
+
+== Limitations
+
+The jOOR Camel language is only supported as a block of Java code that gets compiled into a Java class with a single method.
+The code that you can write is therefore limited to a number of Java statements.
+
+The supported runtime is intended for Java standalone, Spring Boot, Camel Quarkus and other microservices runtimes.
+It is not supported in OSGi, Camel Karaf or any kind of Java Application Server runtime.
 
 == Dependencies
 
diff --git a/docs/components/modules/languages/pages/joor-language.adoc b/docs/components/modules/languages/pages/joor-language.adoc
index 6d69884..716daea 100644
--- a/docs/components/modules/languages/pages/joor-language.adoc
+++ b/docs/components/modules/languages/pages/joor-language.adoc
@@ -36,9 +36,9 @@ The jOOR language supports 4 options, which are listed below.
 |===
 // language options: END
 
-=== Variables
+== Variables
 
-The jOOR language allows the following variables to be used in the script
+The jOOR language allows the following variables to be used in the script:
 
 [width="100%",cols="2,1m,7",options="header"]
 |===
@@ -49,7 +49,7 @@ The jOOR language allows the following variables to be used in the script
 | body | Object | The message body
 |===
 
-=== Sample
+== Sample
 
 For example to transform the message using jOOR language to upper case
 
@@ -72,7 +72,7 @@ And in XML DSL:
 </route>
 ----
 
-=== Multi statements
+== Multi statements
 
 It is possible to include multiple statements, for example where we in the first statement gets the `user` header.
 And then in the 2nd statement we return a value whether the user is `null` or not.
@@ -93,8 +93,44 @@ from("seda:orders")
   .to("seda:user");
 ----
 
-=== Limitations
+== Hot re-load
 
+You can turn of pre compilation for the jOOR language and then Camel will recompile the script for each message.
+You can externalize the code into a resource file, which will be reloaded on each message as shown:
+
+[source,java]
+----
+JoorLanguage joor = (JoorLanguage) context.resolveLanguage("joor");
+joor.setPreCompile(false);
+
+from("jms:incoming")
+    .transform().joor("resource:file:src/main/resources/orders.joor")
+    .to("jms:orders");
+----
+
+Here the jOOR script is externalized into the file `src/main/resources/orders.joor` which allows you to edit this source
+file while running the Camel application and try the changes with hot-reloading.
+
+In XML DSL its a little bit easier as you can turn off pre-compilation in the `<joor>` XML element:
+
+[source,xml]
+----
+<route>
+    <from uri="jms:incoming"/>
+    <transform>
+      <joor preCompile="false">resource:file:src/main/resources/orders.joor</joor>
+    </transform>
+    <to uri="jms:orders"/>
+</route>
+----
+
+== Limitations
+
+The jOOR Camel language is only supported as a block of Java code that gets compiled into a Java class with a single method.
+The code that you can write is therefore limited to a number of Java statements.
+
+The supported runtime is intended for Java standalone, Spring Boot, Camel Quarkus and other microservices runtimes.
+It is not supported in OSGi, Camel Karaf or any kind of Java Application Server runtime.
 
 == Dependencies