Hi all,
I am using Drools 5.4.0 and I am wondering the reason why Drools may decide to use the "mvel" dialect although "java" has been specified.
I have a rule project running in Eclipse. Now I have removed everything but this rules matching "Entity" objects (having a getFullName() method):
rule "count entities"
salience 10000
when
$e : Entity()
then
end
When I put a breakpoint on the getFullName() method of Entity, and debug the program, the breakpoint is not hit (demonstrating that it is not called anywhere else).
Now I am modifying the rule:
rule "count entities"
salience 10000
when
$e : Entity(this.getFullName() != null)
then
end
The breakpoint is now hit and the stack is showing mvel classes:
Entity.getFullName(NameNode.java:82)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:1105)
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:987)
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:377)
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:143)
org.mvel2.ast.ASTNode.optimize(ASTNode.java:159)
org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:115)
org.mvel2.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:107)
org.mvel2.MVELRuntime.execute(MVELRuntime.java:85)
org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:123)
org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:116)
org.mvel2.MVEL.executeExpression(MVEL.java:930)
org.drools.rule.constraint.MvelConditionEvaluator.evaluate(MvelConditionEvaluator.java:70)
org.drools.rule.constraint.MvelConditionEvaluator.evaluate(MvelConditionEvaluator.java:49)
org.drools.rule.constraint.MvelConstraint.evaluate(MvelConstraint.java:167)
org.drools.rule.constraint.MvelConstraint.isAllowed(MvelConstraint.java:124)
org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:137)
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:235)
org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:240)
org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:337)
org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:298)
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:888)
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:847)
org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:269)
Is it the expected behavior? If not, do you have an idea of what I am doing wrong? What is puzzling me the most is I am pretty sure I already have observed JavaDialect* classes (during debugging sessions of other rules).
I can observe the same stack (including mvel) whether I do:
rule "count entities"
salience 10000
dialect "java"
when
$e : Entity(this.getFullName() != null)
then
end
Or:
rule "count entities"
salience 10000
dialect "mvel"
when
$e : Entity(this.getFullName() != null)
then
end
Or:
dialect "java"
rule "count entities"
salience 10000
when
$e : Entity(this.getFullName() != null)
then
end
Any help would be very appreciated!
Thanks!
Bruno.