Hi,
Could someone explain to me what this mean in actual code?
setFunctions
If the entry value is a class that has one contructor taking a JexlContext as 
argument, an instance of the namespace will be created at evaluation time. It 
might be a good idea to derive a JexlContext to carry the information used by 
the namespace to avoid variable space pollution and strongly type the 
constructor with this specialized JexlContext.

http://commons.apache.org/jexl/apidocs/index.html

I would like my function to be able to access one of the variable set in the 
JexlContext.
It sound like I should do something like this.

Public class FunctionClass

{
                Public FunctionClass(JexlContext jexlContext)
                {....}

                Public doSomethingWithVariableA()
                {...}
}

JexlContext jc = new MapContext();
Map<String, Object> funcs = new HashMap<String, Object>();
funcs.put(null, new FunctionClass(jc));
CustomJexlEngine jexl = new JexlEngine();
jexl.setFunctions(funcs);
Jc.put("a", "myPreciousValue");
Expression e11 = jexl.createExpression("doSomethingWithVariableA()");
Object result1 = e11.evaluate(jc);

Then my methods in FunctionClass can access the jexlContext and access variable 
"a".  However, I don't understand the paragraph about "avoiding variable space 
pollution".


Thanks, Grace




________________________________
This email message and any attachments are for the sole use of the intended 
recipients and may contain proprietary and/or confidential information which 
may be privileged or otherwise protected from disclosure. Any unauthorized 
review, use, disclosure or distribution is prohibited. If you are not an 
intended recipient, please contact the sender by reply email and destroy the 
original message and any copies of the message as well as any attachments to 
the original message. Local registered entity information: 
http://www.msci.com/legal/local_registered_entities.html

Reply via email to