Appendix A. Mule Expression Language

 

The Mule Expression Language (MEL) is based on the MVFLEX Expression Language (MVEL; see http://mvel.codehaus.org/), a hybrid dynamic/statically typed language. We strongly recommend you get acquainted with MVEL by reading its online documentation (http://mvel.codehaus.org/Language+Guide+for+2.0). MEL itself is also extensively documented online (http://mng.bz/g8sM). This appendix is a quick reference guide to Mule-specific features of MEL. It also provides a quick overview on how to customize MEL to implement custom needs.

A.1. MEL quick reference

Mule binds custom objects, variables, and functions within the MEL context to facilitate accessing Mule resources, processing messages, and so on.

Top-level variables quick reference

The four main context objects exposed by MEL are server, mule, app, and message. Additionally, payload is available as a shortcut to message.payload, flowVars and sessionVars are maps that give access to flow and session variables, and exception is bound if the current event carries an exception.

Before looking in detail at these context helpers, let’s take a quick peek at MVEL. Take a look at this sample script from MVEL’s documentation (http://mvel.codehaus.org/Sample+Scripts):

colors = {'red', 'green', 'blue'};
foreach (c : colors) {
    System.out.println(c + "!");
}

What should strike you is the following:

A.2. Customizing MEL