[rules-users] Can I change the value of a global in a rule consequence?
Shur, Bob
robert.shur at hp.com
Wed Feb 8 18:54:11 EST 2012
The manual says "It is strongly discouraged to set or change a global value from inside your rules..." but it doesn't say it won't work.
I tried this:
========================
global Integer m;
declare DoneInit end
rule "init"
when
then
insert(new DoneInit());
System.out.println("m from Java: " + m);
m = 100;
System.out.println("m modified in init: " + m);
end
rule "use it"
when
DoneInit()
then
System.out.println("use m: " + m);
end
==========================
and got this output:
m from Java: 13
m modified in init: 100
use m: 13
Is this the expected behavior? I'm in a stateless session in case that matters.
More information about the rules-users
mailing list