Repository: camel
Updated Branches:
  refs/heads/master d15029c4b -> e9368518a


Added language component 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/e3e90166
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e3e90166
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e3e90166

Branch: refs/heads/master
Commit: e3e901666e71802a50341a448b663ba9647ad144
Parents: d15029c
Author: Andrea Cosentino <anco...@gmail.com>
Authored: Tue Jun 14 16:39:37 2016 +0200
Committer: Andrea Cosentino <anco...@gmail.com>
Committed: Tue Jun 14 16:39:37 2016 +0200

----------------------------------------------------------------------
 camel-core/src/main/docs/language.adoc | 144 ++++++++++++++++++++++++++++
 docs/user-manual/en/SUMMARY.md         |   1 +
 2 files changed, 145 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/e3e90166/camel-core/src/main/docs/language.adoc
----------------------------------------------------------------------
diff --git a/camel-core/src/main/docs/language.adoc 
b/camel-core/src/main/docs/language.adoc
new file mode 100644
index 0000000..af25217
--- /dev/null
+++ b/camel-core/src/main/docs/language.adoc
@@ -0,0 +1,144 @@
+[[Language-Language]]
+Language
+~~~~~~~~
+
+*Available as of Camel 2.5*
+
+The language component allows you to send link:exchange.html[Exchange]
+to an endpoint which executes a script by any of the supported
+link:languages.html[Languages] in Camel. +
+ By having a component to execute language scripts, it allows more
+dynamic routing capabilities. For example by using the
+link:routing-slip.html[Routing Slip] or link:dynamic-router.html[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
+components if the language of choice mandates it, such as using
+link:groovy.html[Groovy] or link:javascript.html[JavaScript] languages.
+
+[[Language-URIformat]]
+URI format
+^^^^^^^^^^
+
+[source,java]
+------------------------------------------
+language://languageName[:script][?options]
+------------------------------------------
+
+And from Camel 2.11 onwards you can refer to an external resource for
+the script using same notation as supported by the other
+link:language.html[Language]s in Camel
+
+[source,java]
+-----------------------------------------------------------
+language://languageName:resource:scheme:location][?options]
+-----------------------------------------------------------
+
+[[Language-URIOptions]]
+URI Options
+^^^^^^^^^^^
+
+
+// component options: START
+The Language component has no options.
+// component options: END
+
+
+
+// endpoint options: START
+The Language component supports 9 endpoint options which are listed below:
+
+{% raw %}
+[width="100%",cols="2s,1,1m,1m,5",options="header"]
+|=======================================================================
+| Name | Group | Default | Java Type | Description
+| languageName | producer |  | String | *Required* Sets the name of the 
language to use
+| resourceUri | producer |  | String | Path to the resource or a reference to 
lookup a bean in the Registry to use as the resource
+| binary | producer | false | boolean | Whether the script is binary content 
or text content. By default the script is read as text content (eg 
java.lang.String)
+| cacheScript | producer | false | boolean | Whether to cache the compiled 
script and reuse Notice reusing the script can cause side effects from 
processing one Camel org.apache.camel.Exchange to the next 
org.apache.camel.Exchange.
+| contentCache | producer | false | boolean | Sets whether to use resource 
content cache or not.
+| script | producer |  | String | Sets the script to execute
+| transform | producer | true | boolean | Whether or not the result of the 
script should be used as message body. This options is default true.
+| exchangePattern | advanced | InOnly | ExchangePattern | Sets the default 
exchange pattern when creating an exchange.
+| synchronous | advanced | false | boolean | Sets whether synchronous 
processing should be strictly used or Camel is allowed to use asynchronous 
processing (if supported).
+|=======================================================================
+{% endraw %}
+// endpoint options: END
+
+
+[[Language-MessageHeaders]]
+Message Headers
+^^^^^^^^^^^^^^^
+
+The following message headers can be used to affect the behavior of the
+component
+
+[width="100%",cols="10%,90%",options="header",]
+|=======================================================================
+|Header |Description
+
+|`CamelLanguageScript` |The script to execute provided in the header. Takes 
precedence over
+script configured on the endpoint.
+|=======================================================================
+
+[[Language-Examples]]
+Examples
+^^^^^^^^
+
+For example you can use the link:simple.html[Simple] language to
+link:message-translator.html[Message Translator] a message:
+
+In case you want to convert the message body type you can do this as
+well:
+
+You can also use the link:groovy.html[Groovy] language, such as this
+example where the input message will by multiplied with 2:
+
+You can also provide the script as a header as shown below. Here we use
+link:xpath.html[XPath] language to extract the text from the `<foo>`
+tag.
+
+[source,java]
+--------------------------------------------------------------------------------------------------------------------------------
+Object out = producer.requestBodyAndHeader("language:xpath", "<foo>Hello 
World</foo>", Exchange.LANGUAGE_SCRIPT, "/foo/text()");
+assertEquals("Hello World", out);
+--------------------------------------------------------------------------------------------------------------------------------
+
+[[Language-Loadingscriptsfromresources]]
+Loading scripts from resources
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+*Available as of Camel 2.9*
+
+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:
+
+For example to load a script from the classpath:
+
+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
+updated script is used:
+
+From *Camel 2.11* onwards you can refer to the resource similar to the
+other link:language.html[Language]s in Camel by prefixing with
+`"resource:"` as shown below:
+
+[[Language-SeeAlso]]
+See Also
+^^^^^^^^
+
+* link:configuring-camel.html[Configuring Camel]
+* link:component.html[Component]
+* link:endpoint.html[Endpoint]
+* link:getting-started.html[Getting Started]
+* link:languages.html[Languages]
+* link:routing-slip.html[Routing Slip]
+* link:dynamic-router.html[Dynamic Router]
+* link:script.html[Script]
+

http://git-wip-us.apache.org/repos/asf/camel/blob/e3e90166/docs/user-manual/en/SUMMARY.md
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/SUMMARY.md b/docs/user-manual/en/SUMMARY.md
index a7dde9f..b30bb82 100644
--- a/docs/user-manual/en/SUMMARY.md
+++ b/docs/user-manual/en/SUMMARY.md
@@ -84,6 +84,7 @@
     * [Direct](direct.adoc)
     * [Direct-vm](direct-vm.adoc)
     * [File](file.adoc)
+    * [Language](language.adoc)
     * [Mock](mock.adoc)
     * [Properties](properties.adoc)
 

Reply via email to