Here is a simpler example where the behavior differs depending on whether you assert the fact first or load the rules first. This is just a simple fact class with a string variable called field1. I create and assert the fact with the string "hello" for field1, then I load the following rule file:
<br><br>package com.vsasset.rules.isolate;<br>import java.lang.String;<br><br>rule "simpleDependence"<br>no-loop true<br> when<br> a: factA(field1=="hello")<br> then<br> a.setField1
("world");<br> modify(a);<br> System.out.println("a: " + a.getField1());<br> TestCase.fireRules();<br>end<br>rule "simpleRetract"<br>no-loop true<br> when<br> a: factA(field1 == "world")
<br> then<br> retract(a);<br> System.out.println("Retracted a");<br>end<br><br><br>The second rule (simpleRetract) does not print when the initial factA is asserted before the rules are loaded. If the rules are loaded first, then the second rule prints.
<br><br>To be honest, I'm not sure whether to expect the second rule to print -- does it get immediately de-activated upon the retract so that any further statements are not executed?<br><br>In any event, I would expect the behavior to be the same whether I assert factA first or load the rules first.
<br><br>Am I missing something fundamental? Perhaps I am mis-using the API...<br><br>Thanks,<br>Justine<br><br>