A context object in MVEL is an optional enviromental element that can be used in conjunction with, or an alternative to, injected variables into the parser/interpreter.
For example:
In this example, we're using the test String object as our context object, allowing us to execute the toUpperCase() method as a local function in our expression. We can also access other methods in the java.util.String class as bean properties.
Consider:
Now, just for example purposes, lets apply this class in one of our tests:
In this example, the value of the variable name returned by the expression will be "Bob".
Priority of Resolution
In situations where both external variables and a context object are being used, the MVEL runtime will look for a variable first, and then look to see if the context object contains the identifier.