01: package org.drools.base.mvel;
02:
03: import java.io.Serializable;
04:
05: import org.drools.WorkingMemory;
06: import org.drools.spi.Consequence;
07: import org.drools.spi.KnowledgeHelper;
08: import org.mvel.CompiledExpression;
09: import org.mvel.MVEL;
10:
11: public class MVELConsequence implements Consequence, Serializable {
12: private static final long serialVersionUID = 400L;
13:
14: private final Serializable expr;
15: private final DroolsMVELFactory factory;
16:
17: public MVELConsequence(final Serializable expr,
18: final DroolsMVELFactory factory) {
19: this .expr = expr;
20: this .factory = factory;
21: }
22:
23: public void evaluate(final KnowledgeHelper knowledgeHelper,
24: final WorkingMemory workingMemory) throws Exception {
25: this .factory.setContext(knowledgeHelper.getTuple(),
26: knowledgeHelper, null, workingMemory, null);
27: CompiledExpression compexpr = (CompiledExpression) this .expr;
28:
29: //Receive breakpoints from debugger
30: MVELDebugHandler.prepare();
31:
32: if (MVELDebugHandler.isDebugMode()) {
33: MVEL.executeDebugger(compexpr, null, this .factory);
34: } else {
35: MVEL.executeExpression(compexpr, null, this .factory);
36: }
37:
38: }
39:
40: public Serializable getCompExpr() {
41: return expr;
42: }
43:
44: }
|