<br> Well, I'm not sure why are you constraining your rule using the class Object. What is happening is that the engine always inserts a fact into the engine known as InitialFact, that as all objects in java, is a subclass of Object, and that is why the rule fires.
<br> If instead of Object, you use a different class, like Integer for instance, to constrain your rule, you will get the behavior you are looking for.<br><br> []s<br> Edson<br><br><div><span class="gmail_quote">2007/8/22, Dean Jones <
<a href="mailto:dean.m.jones@gmail.com">dean.m.jones@gmail.com</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br><br>I have the following simple rulebase:
<br><br>package org.drools.examples<br>rule "Hello World"<br> when<br> o : Object( )<br> then<br> System.out.println("Hello world (o=" + o + ")");<br>end<br>
rule "Goodbye World"<br> when<br> not Object( )<br> then<br> System.out.println("Goodbye cruel world");<br>end<br><br>and the following code:<br><br>public class TestReadRuleFile {
<br><br>public static void main(String[] args) throws Exception {<br> PackageBuilder builder = new PackageBuilder();<br> builder.addPackageFromDrl(<br> new InputStreamReader(<br> TestReadRuleFile.class.getResourceAsStream
("test.drl")));<br> Package pkg = builder.getPackage();<br> RuleBase rulebase = RuleBaseFactory.newRuleBase();<br> rulebase.addPackage(pkg);<br> StatefulSession session = rulebase.newStatefulSession();<br>
session.fireAllRules();<br>}<br><br>}<br><br>which produces the following output:<br><br>Hello world (o=org.drools.reteoo.InitialFactImpl@4dde85f0)<br><br>I expected the "Goodbye World" rule to fire, as there should not be
<br>any Objects in the working memory. If I change my code to insert an<br>object into the working memory as follows:<br><br> session.insert(new Object());<br><br>I now get the following output:<br><br>Hello world (o=org.drools.reteoo.InitialFactImpl@4dde85f0
)<br>Hello world (o=java.lang.Object@17ba38f)<br><br>In this case, I expected the "Hello World" rule to fire only once. Any<br>thoughts on what I'm doing wrong here?<br><br>Thanks,<br><br>Dean.<br>_______________________________________________
<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users
</a><br></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> Software Engineer - JBoss Rules Core Developer<br> Office: +55 11 3529-6000<br> Mobile: +55 11 9287-5646<br> JBoss, a division of Red Hat @
<a href="http://www.jboss.com">www.jboss.com</a>