
| This is | ![]() |
Java Expression for Dynamic Invocation | |
JEDI is a fork of jakarta commons JEXL. The reasons of this modified version reside in a different approach in variable resolution of JexlContext, now JediContext.
JexlContext is nothing more than a map of (variable names, variable values), while JediContext hides the implementation
details of variable names resolution.
However, this silght modification allows great flexibility in providing JediContext implementations.
See javadoc of org.omj.jedi.context for some example of the new resolution style.
The following example shows a basic usage of JEDI:
// Create an expression object
String exp = "foo.innerFoo.bar()";
Expression e = ExpressionFactory.createExpression( exp );
// Create a context and add data
Map vars = new HashMap();
vars.put("foo", new Foo() );
JediContext jc = JediMapContext(vars);
// Now evaluate the expression, getting the result
Object o = e.evaluate(jc);
Next example shows JEDI capabilities in extending JediContext.
// Create an expression object
String exp = "foo.innerFoo.bar(System.currentTimeMillis())";
Expression e = ExpressionFactory.createExpression( exp );
// Create root context with common variables
Map rootvars = new HashMap();
rootvars.put("System", System.class);
JediContext rootctx = JediMapContext(rootvars);
// Create a new context for local variables
Map vars = new HashMap();
vars.put("foo", new Foo() );
JediContext ctx = JediMapContext(vars);
// Create resolution context for local variables that inherits from root context
JediContext ctx = new JediDelegatingExtensibleContext(ctx, rootctx);
// Now evaluate the expression, getting the result
Object o = e.evaluate(jc);
Download JEDI source distribution
For any comment on this site, drop a mail to webmaster
For any comment, question, suggestion on the various packages contact voodoo@objectmagic.org (Yes, even for bug report)