use of org.mule.mvel2.integration.VariableResolverFactory in project jbpm by kiegroup.
the class MVELAction method execute.
public void execute(ProcessContext context) throws Exception {
int length = unit.getOtherIdentifiers().length;
Object[] vars = new Object[length];
if (unit.getOtherIdentifiers() != null) {
for (int i = 0; i < length; i++) {
vars[i] = context.getVariable(unit.getOtherIdentifiers()[i]);
}
}
InternalWorkingMemory internalWorkingMemory = null;
if (context.getKieRuntime() instanceof StatefulKnowledgeSessionImpl) {
internalWorkingMemory = ((StatefulKnowledgeSessionImpl) context.getKieRuntime()).getInternalWorkingMemory();
} else if (context.getKieRuntime() instanceof StatelessKnowledgeSessionImpl) {
StatefulKnowledgeSession statefulKnowledgeSession = ((StatelessKnowledgeSessionImpl) context.getKieRuntime()).newWorkingMemory();
internalWorkingMemory = ((StatefulKnowledgeSessionImpl) statefulKnowledgeSession).getInternalWorkingMemory();
}
VariableResolverFactory factory = unit.getFactory(context, // No previous declarations
null, // No rule
null, // No "right object"
null, // No (left) tuples
null, vars, internalWorkingMemory, (GlobalResolver) context.getKieRuntime().getGlobals());
// KnowledgePackage pkg = context.getKnowledgeRuntime().getKnowledgeBase().getKnowledgePackage( "MAIN" );
// if ( pkg != null && pkg instanceof KnowledgePackageImp) {
// MVELDialectRuntimeData data = ( MVELDialectRuntimeData ) ((KnowledgePackageImp) pkg).pkg.getDialectRuntimeRegistry().getDialectData( id );
// factory.setNextFactory( data.getFunctionFactory() );
// }
//
MVELSafeHelper.getEvaluator().executeExpression(this.expr, null, factory);
}
use of org.mule.mvel2.integration.VariableResolverFactory in project mvel by mikebrock.
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 mikebrock.
the class ForNode method getReducedValueAccelerated.
public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
VariableResolverFactory ctxFactory = indexAlloc ? factory : new MapVariableResolverFactory(new HashMap<String, Object>(1), factory);
Object v;
for (initializer.getValue(ctx, thisValue, ctxFactory); (Boolean) condition.getValue(ctx, thisValue, ctxFactory); after.getValue(ctx, thisValue, ctxFactory)) {
v = compiledBlock.getValue(ctx, thisValue, ctxFactory);
if (ctxFactory.tiltFlag())
return v;
}
return null;
}
use of org.mule.mvel2.integration.VariableResolverFactory in project mvel by mikebrock.
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 mikebrock.
the class CoreConfidenceTests method testThisReferenceMapVirtualObjects.
// interpreted
public void testThisReferenceMapVirtualObjects() {
Map<String, String> map = new HashMap<String, String>();
map.put("foo", "bar");
VariableResolverFactory factory = new MapVariableResolverFactory(new HashMap<String, Object>());
factory.createVariable("this", map);
assertEquals(true, eval("this.foo == 'bar'", map, factory));
}
Aggregations