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

Chapter 15. EL


Overview

The Unified Expression Language (EL) was originally specified as part of the JSP 2.1 standard (JSR-245), but it is now available as a standalone language. Apache Camel integrates with JUEL (http://juel.sourceforge.net/), which is an open source implementation of the EL language.

Adding JUEL package

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

Example 15.1. Adding the camel-juel dependency

<!-- Maven POM File -->
<properties>
  <camel-version>2.21.0.fuse-740039-redhat-00001</camel-version>
  ...
</properties>

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

Static import

To use the el() static method in your application code, include the following import statement in your Java source files:

import static org.apache.camel.language.juel.JuelExpression.el;

Variables

Table 15.1, “EL variables” lists the variables that are accessible when using EL.

Table 15.1. EL variables
VariableTypeValue

exchange

org.apache.camel.Exchange

The current Exchange

in

org.apache.camel.Message

The IN message

out

org.apache.camel.Message

The OUT message

Example

Example 15.2, “Routes using EL” shows two routes that use EL.

Example 15.2. Routes using EL

<camelContext>
  <route>
    <from uri="seda:foo"/>
    <filter>
      <language language="el">${in.headers.foo == 'bar'}</language>
      <to uri="seda:bar"/>
    </filter>
  </route>
  <route>
    <from uri="seda:foo2"/>
    <filter>
      <language language="el">${in.headers['My Header'] == 'bar'}</language>
      <to uri="seda:bar"/>
    </filter>
  </route>
</camelContext>
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

© 2024 Red Hat, Inc.