[rules-users] How to define static constant variable

Esteban Aliverti esteban.aliverti at gmail.com
Tue Nov 22 09:08:07 EST 2011


So these are not "constants" :).
I think a better approach could be to model your "constants" in a Fact
class.
Then, you can insert/update/retract this fact inside your rules.
For examples:

rule 1
when
   Something()
then
   //init "values" fact
   Values v = new Values();
   v.set...
   insert (v)
end

rule 2
when
   $v: Values()
   Other(amount > $v.maxAmount)
then
   //you can also use $v here
end


Best Regards,

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Esteban Aliverti
- Developer @ http://www.plugtree.com
- Blog @ http://ilesteban.wordpress.com


On Tue, Nov 22, 2011 at 2:59 PM, Zhao Yi <zhaoyi0113 at gmail.com> wrote:

> There are some constant variables will be used in rules. For example, I
> have
> a maximum and minimum value which are used to limited other values. So I
> need to define these values in rules. If I set global variable, I have to
> set these global on the session in java code. How can I set them in rules
> without change Java code?
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/How-to-define-static-constant-variable-tp3527416p3527761.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20111122/82bbb4f5/attachment.html 


More information about the rules-users mailing list