camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [3/3] camel git commit: Added camel-jxpath docs to Gitbook
Date Tue, 03 May 2016 07:00:13 GMT
Added camel-jxpath 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/9b69d171
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9b69d171
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9b69d171

Branch: refs/heads/master
Commit: 9b69d1719914dc2992b6a3318624393e0b6816a9
Parents: eb51dfb
Author: Andrea Cosentino <ancosen@gmail.com>
Authored: Tue May 3 08:46:52 2016 +0200
Committer: Andrea Cosentino <ancosen@gmail.com>
Committed: Tue May 3 08:59:54 2016 +0200

----------------------------------------------------------------------
 .../camel-jxpath/src/main/docs/jxpath.adoc      | 150 +++++++++++++++++++
 docs/user-manual/en/SUMMARY.md                  |   1 +
 2 files changed, 151 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/9b69d171/components/camel-jxpath/src/main/docs/jxpath.adoc
----------------------------------------------------------------------
diff --git a/components/camel-jxpath/src/main/docs/jxpath.adoc b/components/camel-jxpath/src/main/docs/jxpath.adoc
new file mode 100644
index 0000000..ff962f3
--- /dev/null
+++ b/components/camel-jxpath/src/main/docs/jxpath.adoc
@@ -0,0 +1,150 @@
+[[JXPath-JXPath]]
+JXPath
+~~~~~~
+
+Camel supports http://commons.apache.org/jxpath/[JXPath] to allow
+link:xpath.html[XPath] expressions to be used on beans in an
+link:expression.html[Expression] or link:predicate.html[Predicate] to be
+used in the link:dsl.html[DSL] or link:xml-configuration.html[Xml
+Configuration]. For example you could use JXPath to create an
+link:predicate.html[Predicate] in a link:message-filter.html[Message
+Filter] or as an link:expression.html[Expression] for a
+link:recipient-list.html[Recipient List].
+
+You can use XPath expressions directly using smart completion in your
+IDE as follows
+
+[source,java]
+---------------------------
+from("queue:foo").filter().
+  jxpath("/in/body/foo").
+  to("queue:bar")
+---------------------------
+
+[[JXPath-Variables]]
+Variables
+^^^^^^^^^
+
+[width="100%",cols="10%,10%,80%",options="header",]
+|=======================================================================
+|Variable |Type |Description
+
+|*this* |Exchange |the Exchange object
+
+|in |Message |the exchange.in message
+
+|out |Message |the exchange.out message
+|=======================================================================
+
+[[JXPath-Options]]
+Options
+^^^^^^^
+
+[width="100%",cols="10%,10%,80%",options="header",]
+|=======================================================================
+|Option |Type |Description
+
+|lenient |boolean |*Camel 2.11/2.10.5:* Allows to turn lenient on the JXPathContext. When
+turned on this allows the JXPath expression to evaluate against
+expressions and message bodies which may be invalid / missing data. See
+more details at the
+http://commons.apache.org/proper/commons-jxpath//users-guide.html#Lenient_Mode[JXPath
+Documentation] This option is by default false.
+|=======================================================================
+
+[[JXPath-UsingXMLconfiguration]]
+Using XML configuration
+^^^^^^^^^^^^^^^^^^^^^^^
+
+If you prefer to configure your routes in your link:spring.html[Spring]
+XML file then you can use JXPath expressions as follows
+
+[source,xml]
+---------------------------------------------------------------------------------------------------------------
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
+
+  <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
+    <route>
+      <from uri="activemq:MyQueue"/>
+      <filter>
+        <jxpath>in/body/name = 'James'</xpath>
+        <to uri="mqseries:SomeOtherQueue"/>
+      </filter>
+    </route>
+  </camelContext>
+</beans>
+---------------------------------------------------------------------------------------------------------------
+
+[[JXPath-Examples]]
+Examples
+^^^^^^^^
+
+Here is a simple
+http://svn.apache.org/repos/asf/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/JXPathFilterTest.java[example]
+using a JXPath expression as a predicate in a
+link:message-filter.html[Message Filter]
+
+[[JXPath-JXPathinjection]]
+JXPath injection
+~~~~~~~~~~~~~~~~
+
+You can use link:bean-integration.html[Bean Integration] to invoke a
+method on a bean and use various languages such as JXPath to extract a
+value from the message and bind it to a method parameter.
+
+For example
+
+[source,java]
+---------------------------------------------------------------------------------------------
+public class Foo {
+    
+    @MessageDriven(uri = "activemq:my.queue")
+    public void doSomething(@JXPath("in/body/foo") String correlationID, @Body String body)
{
+        // process the inbound message here
+    }
+}
+---------------------------------------------------------------------------------------------
+
+[[JXPath-Loadingscriptfromexternalresource]]
+Loading script from external resource
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+*Available as of Camel 2.11*
+
+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:
+
+[source,java]
+----------------------------------------------------------------
+.setHeader("myHeader").jxpath("resource:classpath:myjxpath.txt")
+----------------------------------------------------------------
+
+[[JXPath-Dependencies]]
+Dependencies
+^^^^^^^^^^^^
+
+To use JXpath in your camel routes you need to add the a dependency on
+*camel-jxpath* which implements the JXpath language.
+
+If you use maven you could just add the following to your pom.xml,
+substituting the version number for the latest & greatest release (see
+link:download.html[the download page for the latest versions]).
+
+[source,java]
+---------------------------------------
+<dependency>
+  <groupId>org.apache.camel</groupId>
+  <artifactId>camel-jxpath</artifactId>
+  <version>x.x.x</version>
+</dependency>
+---------------------------------------
+
+Otherwise, you'll also need
+http://repo2.maven.org/maven2/commons-jxpath/commons-jxpath/1.3/commons-jxpath-1.3.jar[Commons
+JXPath].

http://git-wip-us.apache.org/repos/asf/camel/blob/9b69d171/docs/user-manual/en/SUMMARY.md
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/SUMMARY.md b/docs/user-manual/en/SUMMARY.md
index 636cd25..14bb674 100644
--- a/docs/user-manual/en/SUMMARY.md
+++ b/docs/user-manual/en/SUMMARY.md
@@ -197,6 +197,7 @@
     * [Constant](constant.adoc)
     * [EL](juel.adoc)
     * [Jsonpath](jsonpath.adoc)
+    * [JXPath](jxpath.adoc)
     * [SQL](josql.adoc)
 
 * Data Formats


Mime
View raw message