To provide greater flexibility when parsing and processing messages, Apache Camel supports language plug-ins for various scripting languages. For example, if an incoming message is formatted as XML, it is relatively easy to extract the contents of particular XML elements or attributes from the message using a language such as XPath. The Apache Camel implements script builder classes, which encapsulate the imported languages. Each language is accessed through a static method that takes a script expression as its argument, processes the current message using that script, and then returns an expression or a predicate.
Red Hat Fuse IDE's Property Editor uses a drop-down list to specify
the language used in an expression. The combination of the Expression
field and the associated Language field is translated into a
language
element in the generated XML. The
language
element has a language
attribute that specifies the language used to interpret the expression. The content of the
element must be a script written in the relevant language. At runtime, the return value
of the script is read by the parent element.
Table 1, “Available languages” lists the values for the Language attribute.
Table 1. Available languages
Language | Attribute Value | Description |
---|---|---|
Constant | constant | Allows the use of constants as an expression. |
EL | el | The Unified Expression Language (EL), originally developed as part of the JSP standard (see http://juel.sourceforge.net/). |
Groovy | groovy | The Groovy scripting language (see http://groovy.codehaus.org/). |
Header | header | Extracts the value of a named header. |
JavaScript | javaScript | The JavaScript scripting language (see http://developer.mozilla.org/en/docs/JavaScript), also known as ECMAScript (see http://www.ecmascript.org/). |
MVEL | mvel | The MVEL expression language (see http://mvel.codehaus.org/). |
OGNL | ognl | The OGNL (Object Graph Navigation Language) language (see http://www.ognl.org/). |
PHP | php | The PHP scripting language (see http://www.php.net/). |
Property | property | Extracts the value of a named property. |
Python | python | The Python scripting language (see http://www.python.org/). |
Ruby | ruby | The Ruby scripting language (see http://www.ruby-lang.org/). |
Simple | simple | A simple expression language, native to Apache Camel. |
SQL | sql | The JoSQL language, which is a language for extracting and manipulating data from collections of Java objects, using a SQL-like syntax (see http://josql.sourceforge.net/). |
XPath | xpath | The XPath language, which is used to select element, attribute, and text nodes from XML documents (see http://www.w3schools.com/xpath/default.asp). The XPath expression is applied to the current message. |
XQuery | xquery | The XQuery language, which is an extension of XPath (see http://www.w3schools.com/xquery/default.asp). The XQuery expression is applied to the current message. |