[rules-users] declared variables in rules loaded to the same knowledge base

Salina Fung/UFL - ICIL salina at icil.net
Wed Feb 8 23:42:58 EST 2012


We have 2 rules - rule 1 and rule 2, both have
declared variable @role(event)

In the program with statements to define the rule

<<
String rule1 = "package test001 import com.icil.event.*; declare EventImpl
@role(event) end rule \"test 001\" when Integer() then
System.out.println(\"rule test 001: there is an integer\"); end ";

String rule2 = "package test002 import com.icil.event.*; declare EventImpl
@role(event) end rule \"test 002\" when Integer() then
System.out.println(\"rule test 002: there is an integer\"); end ";
>>

and then  try to load these two into the same knowledge base using Drools 5.3,
will get an runtime exception. But Drools 5.2, this is ok, with
no error.


Then in Drools 5.2
 
We try to print the address of the variable 'event' in the RHS of both rules, the
address is the same in both rules, which means they are sharing the same instance?  

Is it the declared variables with the same name in separate
rules being loaded in the same knowledge base, will just
have ONE instance?



Thanks
Salina




More information about the rules-users mailing list