Print
Integration Guide

MVEL is easy to integrate, but there are some basic things you need to be aware of first.

The MVEL Runtime is divided into two distinct modes: interpreted and accelerated (or compiled). The interpreted mode is a stateless, ad-hoc mode that compiles and executes on-the-fly. Unlike the compiled mode, no AST is generated, but rather, the expression is reduced as soon as it's possible to do so. The compiled mode produces a fully normalized AST of the expression for caching and re-execution. For speed-sensitive applications where the expression is called often, the second option may be preferable.

In addition to the AST compiler, MVEL comes packaged with a Just-in-Time (JIT) Accelerating Compiler which will compile parts of the expression down to Java bytecode in order to achieve even higher performance. By default: the JIT is enabled and will optimize expressions automatically. If this is not desired, see Disabling the JIT Compiler.

Dependencies

MVEL 1.2 is self-contained and does not require any dependencies. All JARs that ship with the distribution are for the benefit of the unit test suite. Production use of MVEL only requires the mvel.jar file.

The MVEL Convenience Class

In order to make integration of MVEL simple and straight-forward, most common use cases have been wrapped into simple static methods which can be called from the integration points of your application.

The fully qualified name for the MVEL class is:

Virtually all integration will revolve around the use of the class.

Interpreted Mode

As stated in the introduction to this section, the interpreted mode is a fast, on-the-fly parser-interpreter in MVEL. And by fast, we mean, fast. The MVEL interpreter is faster than some other EL implementations factory caching and compiled execution.

Calling the interpreter is focused around the eval() group of methods in the MVEL< class.

Integration Example: MVELTest.java

Compiled Mode

Compiling and executing an expression, requires a little bit more work than simply calling one method. It involves calling two methods!

Integration Example: MVELTest2.java

... Almost identical to to interpreted mode.

Powered by Atlassian Confluence