|
|||||
|
|||||
Useful Things |
Getting Started Guide
MVEL is very easy to use, and just as easy to integrate into your application. Let's take a quick look at a simple MVEL expression: This simple expression asks MVEL if the value of
A context object is something you can use as the base of your expression by which MVEL will attempt to map identifiers to. Consider the following example: Lets say we decide to make an instance of this particular class the context object for the expression, and we evaluate it like so: When we execute this expression using the eval() method, we will get a result. In this particular case, the value of If we wanted to simply extract the value of name from the person instance, we could do that as well: Pretty simple stuff. But what if we want to inject a bunch of variables? MVEL supports that too, and there is both and easy way and a more advanced way (dealing with resolvers – which we won't get to here). The easy way simply involves passing in a Map of variables (names and values), like so: Now, so far we've just been looking at using MVEL as a purely interpreted tool. MVEL can also compile expressions to execute them much faster using a different API. Let's convert the last expression into a compiled version: Next StepsI hope that wets your appetite. Anyways, you can continue on to the Language Guide and Integration Guide's for lots more information. |
||||
|
Copyright 2003-2006 - The Codehaus. All rights reserved unless otherwise noted.
Powered by Atlassian Confluence
|
|||||