I believe this is a bug. After I remove a rule or package from the ruleBase,
newly added rules fail to "see" objects in the working memory. Attached is a
test case, and below is the output from it.
Drools 4.0.4
Java 1.5.0.13
Start
RuleBase created
Adding rules about 'tom':
package tom;
import test.Tester.Record;
rule "Find tom"
when
$rec : Record( field1 == "tom" )
then
System.out.println("Find 'tom' " + $rec.dump());
end
inserting record 1:"tom",
inserting record 2:"fred",
inserting record 3:"harry",
inserting record 4:"fred",
inserting record 5:"ed",
inserting record 6:"tom",
inserting record 7:"sreeni",
inserting record 8:"jill",
inserting record 9:"ed",
inserting record 10:"tom",
fireAllRules()
Find 'tom' 10:"tom",
Find 'tom' 6:"tom",
Find 'tom' 1:"tom",
adding rules about 'fred':
package fred;
import test.Tester.Record;
rule "Find fred"
when
$rec : Record( field1 == "fred" )
then
System.out.println("Find 'fred' " + $rec.dump());
end
Find 'fred' 4:"fred",
Find 'fred' 2:"fred",
As expected, 'fred' is found.
Removing package tom (same bug if you use "ruleBase.removeRule").
ruleBase.removePackage("tom");
adding rules about 'ed':
package ed;
import test.Tester.Record;
rule "Find ed"
when
$rec : Record( field1 == "ed" )
then
System.out.println("Find 'ed' " + $rec.dump());
end
No 'ed' is found!
Changing record 3 to 'ed'
fireAllRules()
Find 'ed' 3:"ed",
Only the newly updated 'ed' is found.
--
Dirk Bergstrom dirk(a)juniper.net
_____________________________________________
Juniper Networks Inc., Computer Geek
Tel: 408.745.3182 Fax: 408.745.8905