[rules-users] MVEL wows: what does "importInjectionRequired" mean?

Barry Kaplan groups1 at memelet.com
Wed Dec 2 13:24:54 EST 2009


I'm at my wits end. I have two simple rules in two separate packages, they
are of the form:

rule1:
  import somepackage.*
  global somepackage.Foo foo
  ...
  then
     foo.doSomething(...)
  end

rule2:
  import otherpackage.*
  global otherpackage.Gar gar
  ...
  then
     gar.doSomething(...)
  end

When mvel is resolving foo for rule1 it does so via
org.mvel2.compiler.CompiledExpression#getValue:line-104

When resolving gar for rule2 it does so via
org.mvel2.compiler.CompiledExpression#getValue:line-107

The difference is that for rule1 the variable 'importInjectionRequired' is
true, which results in 'foo' being resolved, but for rule2 this variable is
false which results in 'gar' not being resolved.

I suspecting that its important that the packages and the global instances
are added dynamically *after* the session is created (in scala'ish dialect):

val session = createSessionUsingNoPackages

val kbuilder1 = KnowledgeBuilderFactory.newKnowledgeBuilder
kbuilder1.add("rule1.drl", ResourceType.DRL)
session.knowledgeBase addKnowledgePackages (kbuilder1.getKnowledgePackages)
session addGlobal ("foo", foo)

val kbuilder2 = KnowledgeBuilderFactory.newKnowledgeBuilder
kbuilder2.add("rule2.drl", ResourceType.DRL)
session.knowledgeBase addKnowledgePackages (kbuilder2.getKnowledgePackages)
session addGlobal ("Gar", gar)

If just one or the other packages are added the session, then either
variable is resolved. But if both are added the session the 'gar' is not
resolved. It does not matter what order they added to the session. I can
also try to access 'gar' in rule1 and it also will not be resolved.

I guess I really don't expect any help on this, but I will boil it down to a
simple test and submit it to jira

-barry
-- 
View this message in context: http://n3.nabble.com/MVEL-wows-what-does-importInjectionRequired-mean-tp66496p66496.html
Sent from the Drools - User mailing list archive at Nabble.com.



More information about the rules-users mailing list