此内容没有您所选择的语言版本。

Chapter 22. JXPath


Overview

The JXPath language enables you to invoke Java beans using the Apache Commons JXPath language. The JXPath language has a similar syntax to XPath, but instead of selecting element or attribute nodes from an XML document, it invokes methods on an object graph of Java beans. If one of the bean attributes returns an XML document (a DOM/JDOM instance), however, the remaining portion of the path is interpreted as an XPath expression and is used to extract an XML node from the document. In other words, the JXPath language provides a hybrid of object graph navigation and XML node selection.

Adding JXPath package

To use JXPath in your routes you need to add a dependency on camel-jxpath to your project as shown in Example 22.1, “Adding the camel-jxpath dependency”.

Example 22.1. Adding the camel-jxpath dependency

<!-- Maven POM File -->
<properties>
  <camel-version>2.17.0.redhat-630xxx</camel-version>
  ...
</properties>

<dependencies>
  ...
  <dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-jxpath</artifactId>
    <version>${camel-version}</version>
  </dependency>
  ...
</dependencies>

Variables

Table 22.1, “JXPath variables” lists the variables that are accessible when using JXPath.
Table 22.1. JXPath variables
VariableTypeValue
thisorg.apache.camel.ExchangeThe current Exchange
inorg.apache.camel.MessageThe IN message
outorg.apache.camel.MessageThe OUT message

Example

Example 22.2, “Routes using JXPath” shows a route that use JXPath.

Example 22.2. Routes using JXPath

<camelContext>
  <route>
    <from uri="activemq:MyQueue"/>
    <filter>
      <jxpath>in/body/name = 'James'</xpath>
      <to uri="mqseries:SomeOtherQueue"/>
    </filter>
  </route>
</camelContext>
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.