Hi everyone,
I am new to this mailing list, I've had a quick look at archives and didn't find anything ont this subject but sorry if this has allready been underlined.
Here is my problem, while I was doing some test on
v3.0.6, 4.0.0 came out, so I started to migrate on the new version. Then I found out an unexpecteed behavior on the 4.0.0.
I have been compiling both with Java 5 and running whith Java 1.5.0_11. And I used versions with dependencies on both tests.
I have made an exemple for you to make it as clear as possible, here is the rule :
---------------------------------------------------------------------------------------
package rules
rule "TwoCheeses"
when
$cheese1 : Cheese();
$cheese2 : Cheese();
then
System.out.println($cheese1);
System.out.println($cheese2);
System.out.println("TwoCheeses");
end
---------------------------------------------------------------------------------------
When I run it on V3.0.6, with this code :
---------------------------------------------------------------------------------------
package rules;
import java.io.InputStreamReader;
import org.drools.RuleBase;
import org.drools.RuleBaseFactory;
import org.drools.WorkingMemory;
import org.drools.compiler.PackageBuilder;
public class Cheese {
public static void main(String[] args) throws Exception{
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl(new InputStreamReader(Cheese.class.getResourceAsStream
("rule.drl")));
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage(builder.getPackage());
WorkingMemory workingMemory = ruleBase.newWorkingMemory
();
Cheese cheese = new Cheese();
workingMemory.assertObject(cheese);
workingMemory.fireAllRules();
}
}
---------------------------------------------------------------------------------------
The rule doesn't fire, which is normal AMHA since only one Cheese object is asserted to the WM
When I run it on V4.0.0, whith this code :
---------------------------------------------------------------------------------------
package rules;
import java.io.InputStreamReader;
import org.drools.RuleBase;
import org.drools.RuleBaseFactory;
import org.drools.StatefulSession;
import org.drools.compiler.PackageBuilder;
public class Cheese {
public static void main(String[] args) throws Exception{
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl(new InputStreamReader(Cheese.class.getResourceAsStream
("rule.drl")));
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage(builder.getPackage());
StatefulSession statefulSession =
ruleBase.newStatefulSession();
Cheese cheese = new Cheese();
statefulSession.assertObject(cheese);
statefulSession.fireAllRules();
}
}
---------------------------------------------------------------------------------------
Now the rule fires and $cheese1 $cheese2 have the same reference.
I have been searching in all docs, this modification of behavior doesn't seem to be expected, has anyone noticed this?
Thanks for your help.
Chris