Hi,
I have the following simple rulebase:
package org.drools.examples
rule "Hello World"
when
o : Object( )
then
System.out.println("Hello world (o=" + o + ")");
end
rule "Goodbye World"
when
not Object( )
then
System.out.println("Goodbye cruel world");
end
and the following code:
public class TestReadRuleFile {
public static void main(String[] args) throws Exception {
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl(
new InputStreamReader(
TestReadRuleFile.class.getResourceAsStream("test.drl")));
Package pkg = builder.getPackage();
RuleBase rulebase = RuleBaseFactory.newRuleBase();
rulebase.addPackage(pkg);
StatefulSession session = rulebase.newStatefulSession();
session.fireAllRules();
}
}
which produces the following output:
Hello world (o=org.drools.reteoo.InitialFactImpl@4dde85f0)
I expected the "Goodbye World" rule to fire, as there should not be
any Objects in the working memory. If I change my code to insert an
object into the working memory as follows:
session.insert(new Object());
I now get the following output:
Hello world (o=org.drools.reteoo.InitialFactImpl@4dde85f0)
Hello world (o=java.lang.Object@17ba38f)
In this case, I expected the "Hello World" rule to fire only once. Any
thoughts on what I'm doing wrong here?
Thanks,
Dean.