Search in sources :

Example 1 with StatelessKnowledgeSessionImpl

use of org.drools.core.impl.StatelessKnowledgeSessionImpl 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);
}
Also used : InternalWorkingMemory(org.drools.core.common.InternalWorkingMemory) StatelessKnowledgeSessionImpl(org.drools.core.impl.StatelessKnowledgeSessionImpl) VariableResolverFactory(org.mvel2.integration.VariableResolverFactory) StatefulKnowledgeSessionImpl(org.drools.core.impl.StatefulKnowledgeSessionImpl) StatefulKnowledgeSession(org.kie.internal.runtime.StatefulKnowledgeSession)

Aggregations

InternalWorkingMemory (org.drools.core.common.InternalWorkingMemory)1 StatefulKnowledgeSessionImpl (org.drools.core.impl.StatefulKnowledgeSessionImpl)1 StatelessKnowledgeSessionImpl (org.drools.core.impl.StatelessKnowledgeSessionImpl)1 StatefulKnowledgeSession (org.kie.internal.runtime.StatefulKnowledgeSession)1 VariableResolverFactory (org.mvel2.integration.VariableResolverFactory)1