use of org.mule.mvel2.integration.VariableResolverFactory in project mvel by mvel.
the class DebugTools method getAllVariableResolvers.
public static Map<String, VariableResolver> getAllVariableResolvers(VariableResolverFactory rootFactory) {
Map<String, VariableResolver> allVariableResolvers = new HashMap<String, VariableResolver>();
VariableResolverFactory vrf = rootFactory;
do {
for (String var : vrf.getKnownVariables()) {
allVariableResolvers.put(var, vrf.getVariableResolver(var));
}
} while ((vrf = vrf.getNextFactory()) != null);
return allVariableResolvers;
}
use of org.mule.mvel2.integration.VariableResolverFactory in project mvel by mvel.
the class BaseVariableResolverFactory method appendFactory.
public void appendFactory(VariableResolverFactory resolverFactory) {
if (nextFactory == null) {
nextFactory = resolverFactory;
} else {
VariableResolverFactory vrf = nextFactory;
while (vrf.getNextFactory() != null) {
vrf = vrf.getNextFactory();
}
vrf.setNextFactory(nextFactory);
}
}
use of org.mule.mvel2.integration.VariableResolverFactory in project mvel by mvel.
the class CoreConfidenceTests method testMVEL190.
public void testMVEL190() {
ParserContext context = new ParserContext();
context.addImport(Ship.class);
context.addImport(MapObject.class);
context.addInput("obj", MapObject.class);
Object compiled = MVEL.compileExpression("((Ship) obj).getName()", context);
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("obj", new Ship());
VariableResolverFactory varsResolver = new MapVariableResolverFactory(vars);
System.out.println(executeExpression(compiled, varsResolver));
}
use of org.mule.mvel2.integration.VariableResolverFactory in project mvel by mvel.
the class CoreConfidenceTests method testThisReferenceMapVirtualObjects2.
// compiled - asm
public void testThisReferenceMapVirtualObjects2() {
// Create our root Map object
Map<String, String> map = new HashMap<String, String>();
map.put("foo", "bar");
VariableResolverFactory factory = new MapVariableResolverFactory(new HashMap<String, Object>());
factory.createVariable("this", map);
if (!Boolean.getBoolean("mvel2.disable.jit"))
OptimizerFactory.setDefaultOptimizer("ASM");
// Run test
assertEquals(true, executeExpression(compileExpression("this.foo == 'bar'"), map, factory));
}
use of org.mule.mvel2.integration.VariableResolverFactory in project mvel by mvel.
the class CoreConfidenceTests method testInterceptors.
public void testInterceptors() {
Interceptor testInterceptor = new Interceptor() {
public int doBefore(ASTNode node, VariableResolverFactory factory) {
System.out.println("BEFORE Node: " + node.getName());
return 0;
}
public int doAfter(Object val, ASTNode node, VariableResolverFactory factory) {
System.out.println("AFTER Node: " + node.getName());
return 0;
}
};
Map<String, Interceptor> interceptors = new HashMap<String, Interceptor>();
interceptors.put("test", testInterceptor);
executeExpression(compileExpression("@test System.out.println('MIDDLE');", null, interceptors));
}
Aggregations