Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.此内容没有您所选择的语言版本。
Chapter 21. The Object-Graph Navigation Language(OGNL)
Overview 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
OGNL (http://www.opensymphony.com/ognl/) is an expression language for getting and setting properties of Java objects. You use the same expression for both getting and setting the value of a property. The OGNL support is in the
camel-ognl
module.
Adding the OGNL module 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
To use OGNL in your routes you need to add a dependency on
camel-ognl
to your project as shown in Example 21.1, “Adding the camel-ognl dependency”.
Example 21.1. Adding the camel-ognl dependency
Static import 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
To use the
ognl()
static method in your application code, include the following import statement in your Java source files:
import static org.apache.camel.language.ognl.OgnlExpression.ognl;
import static org.apache.camel.language.ognl.OgnlExpression.ognl;
Built-in variables 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
Table 21.1, “OGNL variables” lists the built-in variables that are accessible when using OGNL.
Name | Type | Description |
---|---|---|
this | org.apache.camel.Exchange | The current Exchange |
exchange | org.apache.camel.Exchange | The current Exchange |
exception | Throwable | the Exchange exception (if any) |
exchangeID | String | the Exchange ID |
fault | org.apache.camel.Message | The Fault message(if any) |
request | org.apache.camel.Message | The IN message |
response | org.apache.camel.Message | The OUT message |
properties | Map | The Exchange properties |
property(name) | Object | The value of the named Exchange property |
property(name, type) | Type | The typed value of the named Exchange property |
Example 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
Example 21.2, “Route using OGNL” shows a route that uses OGNL.
Example 21.2. Route using OGNL