Repository: camel
Updated Branches:
  refs/heads/master 72e3b27e5 -> ff99845fb


Added camel-script docs to Gitbook


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/13a7ea9a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/13a7ea9a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/13a7ea9a

Branch: refs/heads/master
Commit: 13a7ea9a3134a26da61f2f3ac6d4642c839a6d4f
Parents: 72e3b27
Author: Andrea Cosentino <anco...@gmail.com>
Authored: Tue May 24 08:59:44 2016 +0200
Committer: Andrea Cosentino <anco...@gmail.com>
Committed: Tue May 24 08:59:58 2016 +0200

----------------------------------------------------------------------
 .../camel-script/src/main/docs/script.adoc      | 102 +++++++++++++++++++
 docs/user-manual/en/SUMMARY.md                  |   1 +
 2 files changed, 103 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/13a7ea9a/components/camel-script/src/main/docs/script.adoc
----------------------------------------------------------------------
diff --git a/components/camel-script/src/main/docs/script.adoc 
b/components/camel-script/src/main/docs/script.adoc
new file mode 100644
index 0000000..7d3a77a
--- /dev/null
+++ b/components/camel-script/src/main/docs/script.adoc
@@ -0,0 +1,102 @@
+[[Script-Script]]
+Script
+~~~~~~
+
+*Available as of Camel 2.16*
+
+Is used to execute a script which does not change the message (by
+default). This is useful when you need to invoke some logic that are not
+in Java code such as JavaScript, Groovy or any of the
+other link:languages.html[Languages]. The message body is not changed
+(by default) however the scripting context has access to the current
+Exchange and can essentially change the message or headers directly. But
+the return value from the script is discarded and not used. If the
+return value should be used as a changed message body then
+use link:message-translator.html[Message Translator] EIP instead.
+
+[[Script-UsingfromJavaDSL]]
+Using from Java DSL
+^^^^^^^^^^^^^^^^^^^
+
+The route below will read the file contents and validate them against a
+regular expression.
+
+[source,java]
+---------------------------------------------------
+from("file://inbox")
+  .script().groovy("// some groovy code goes here")
+  .to("bean:MyServiceBean.processLine");
+---------------------------------------------------
+
+[[Script-UsingfromSpringDSL]]
+Using from Spring DSL
+^^^^^^^^^^^^^^^^^^^^^
+
+And from XML its easy as well
+
+[source,xml]
+--------------------------------------------------------------
+<route>
+  <from uri="file://inbox"/>
+  <script>
+    <groovy>// some groovy code goes here</groovy>
+  </script>
+  <beanRef ref="myServiceBean" method="processLine"/>
+</route>
+
+<bean id="myServiceBean" class="com.mycompany.MyServiceBean"/>
+--------------------------------------------------------------
+
+Mind that you can use CDATA in XML if the groovy scrip uses < > etc
+
+ 
+
+[source,xml]
+-------------------------------------------------------------------------------------------------
+<route>
+  <from uri="file://inbox"/>
+  <script>
+    <groovy><![CDATA[ some groovy script here that can be multiple lines and 
whatnot ]]></groovy>
+  </script>
+  <beanRef ref="myServiceBean" method="processLine"/>
+</route>
+
+<bean id="myServiceBean" class="com.mycompany.MyServiceBean"/>
+-------------------------------------------------------------------------------------------------
+
+[[Script-Usingexternalscriptfiles]]
+Using external script files
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+You can refer to external script files instead of inlining the script.
+For example to load a groovy script from the classpath you need to
+prefix the value with *resource:* as shown:
+
+[source,xml]
+---------------------------------------------------------------
+<route>
+  <from uri="file://inbox"/>
+  <script>
+    <groovy>resource:classpath:com/foo/myscript.groovy</groovy>
+  </script>
+  <beanRef ref="myServiceBean" method="processLine"/>
+</route>
+
+<bean id="myServiceBean" class="com.mycompany.MyServiceBean"/>
+---------------------------------------------------------------
+
+You can also refer to the script from the file system with file: instead
+of classpath: such as file:/var/myscript.groovy
+
+ 
+
+[[Script-UsingThisPattern]]
+Using This Pattern
+++++++++++++++++++
+
+If you would like to use this EIP Pattern then please read the
+link:getting-started.html[Getting Started], you may also find the
+link:architecture.html[Architecture] useful particularly the description
+of link:endpoint.html[Endpoint] and link:uris.html[URIs]. Then you could
+try out some of the link:examples.html[Examples] first before trying
+this pattern out.

http://git-wip-us.apache.org/repos/asf/camel/blob/13a7ea9a/docs/user-manual/en/SUMMARY.md
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/SUMMARY.md b/docs/user-manual/en/SUMMARY.md
index d34ba40..1d7f425 100644
--- a/docs/user-manual/en/SUMMARY.md
+++ b/docs/user-manual/en/SUMMARY.md
@@ -231,6 +231,7 @@
     * [Scp](scp.adoc)
     * [Schematron](schematron.adoc)
     * [SCR](camel-and-scr.adoc)
+    * [Script](script.adoc)
     * [SJMS](sjms.adoc)
     * [SJMS Batch](sjms-batch.adoc)
     * [Telegram](telegram.adoc)

Reply via email to