public object getValue(OgnlContext context, object source) { if (context.getTraceEvaluations()) { EvaluationPool pool = OgnlRuntime.getEvaluationPool(); object result = null; Exception evalException = null; Evaluation evaluation = pool.create(this, source); context.pushEvaluation(evaluation); try { result = evaluateGetValueBody(context, source); } catch (OgnlException ex) { evalException = ex; throw ex; } catch (Exception ex) { evalException = ex; throw ex; } finally { Evaluation eval = context.popEvaluation(); eval.setResult(result); if (evalException != null) { eval.setException(evalException); } if ((evalException == null) && (context.getRootEvaluation() == null) && !context.getKeepLastEvaluation()) { pool.recycleAll(eval); } } return(result); } else { return(evaluateGetValueBody(context, source)); } }
public void setValue(OgnlContext context, object target, object value) { if (context.getTraceEvaluations()) { EvaluationPool pool = OgnlRuntime.getEvaluationPool(); Exception evalException = null; Evaluation evaluation = pool.create(this, target, true); context.pushEvaluation(evaluation); try { evaluateSetValueBody(context, target, value); } catch (OgnlException ex) { evalException = ex; ex.setEvaluation(evaluation); throw ex; } catch (Exception ex) { evalException = ex; throw ex; } finally { Evaluation eval = context.popEvaluation(); if (evalException != null) { eval.setException(evalException); } if ((evalException == null) && (context.getRootEvaluation() == null) && !context.getKeepLastEvaluation()) { pool.recycleAll(eval); } } } else { evaluateSetValueBody(context, target, value); } }
///<summary> /// This method can be called when the last evaluation has been used /// and can be returned for reuse in the free pool maintained by the /// runtime. This is not a necessary step, but is useful for keeping /// memory usage down. This will recycle the last evaluation and then /// set the last evaluation to null. ///</summary> public void recycleLastEvaluation() { OgnlRuntime.getEvaluationPool().recycleAll(lastEvaluation); lastEvaluation = null; }