Chapter 9. Other API features

Table of Contents

Tracing Evaluations

Tracing Evaluations

As of OGNL 2.5.0 the OgnlContext object can automatically tracks evaluations of expressions. This tracking is kept in the OgnlContext as currentEvaluation during the evaluation. After execution you can access the last evaluation through the lastEvaluation property of OgnlContext.

[Note]Note

The tracing feature is turned off by default. If you wish to turn it on there is a setTraceEvaluations() method on OgnlContext that you can call.

Any method accessor, elements accessor, type converter, property accessor or null handler may find this useful to give context to the operation being performed. The Evaluation object is itself a tree and can be traversed up, down and left and right through siblings to determine the exact circumstances of an evaluation. In addition the Evaluation object tracks the node that was performing the operation, the source object on which that operation was being performed and the result of the operation. If an exception is thrown during execution the user can get the last evaluation's last descendent to find out exactly which subexpression caused the error. The execption is also tracked in the Evaluation.