01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: FilteredTagProcessorMvel.java 3759 2007-05-13 21:54:41Z gbevin $
07: */
08: package com.uwyn.rife.template;
09:
10: import java.io.Serializable;
11: import java.util.Map;
12: import org.mvel.MVEL;
13:
14: public class FilteredTagProcessorMvel extends FilteredTagProcessor {
15: private static FilteredTagProcessor sInstance = null;
16:
17: public static FilteredTagProcessor getInstance() {
18: if (null == sInstance) {
19: sInstance = new FilteredTagProcessorMvel();
20: }
21:
22: return sInstance;
23: }
24:
25: public String getLanguage() {
26: return "MVEL";
27: }
28:
29: public Object processExpression(Template template, Class rootType,
30: String rootName, Object rootValue, String expression,
31: Map<String, Object> context) throws Exception {
32: Serializable compiled = (Serializable) template
33: .getCacheObject(expression);
34: if (null == compiled) {
35: compiled = MVEL.compileExpression(expression);
36: template.cacheObject(expression, compiled);
37: }
38:
39: return MVEL.executeExpression(compiled, rootValue, context,
40: Boolean.class);
41: }
42: }
|