So these are not "constants" :). <div>I think a better approach could be to model your "constants" in a Fact class.</div><div>Then, you can insert/update/retract this fact inside your rules.</div><div>For examples:</div>
<div><br></div><div>rule 1</div><div>when</div><div> Something()</div><div>then</div><div> //init "values" fact</div><div> Values v = new Values();</div><div> v.set...</div><div> insert (v) <br clear="all">
end</div><div><br></div><div>rule 2</div><div>when</div><div> $v: Values()</div><div> Other(amount > $v.maxAmount)</div><div>then</div><div> //you can also use $v here</div><div>end</div><div><br></div><div><br>
</div>
<div>Best Regards,</div><div><br>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br><br>Esteban Aliverti<br>- Developer @ <a href="http://www.plugtree.com" target="_blank">http://www.plugtree.com </a><br>- Blog @ <a href="http://ilesteban.wordpress.com" target="_blank">http://ilesteban.wordpress.com</a><br>
<br><br><div class="gmail_quote">On Tue, Nov 22, 2011 at 2:59 PM, Zhao Yi <span dir="ltr"><<a href="mailto:zhaoyi0113@gmail.com">zhaoyi0113@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
There are some constant variables will be used in rules. For example, I have<br>
a maximum and minimum value which are used to limited other values. So I<br>
need to define these values in rules. If I set global variable, I have to<br>
set these global on the session in java code. How can I set them in rules<br>
without change Java code?<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/How-to-define-static-constant-variable-tp3527416p3527761.html" target="_blank">http://drools.46999.n3.nabble.com/How-to-define-static-constant-variable-tp3527416p3527761.html</a><br>
</font></span><div class="HOEnZb"><div class="h5">Sent from the Drools: User forum mailing list archive at Nabble.com.<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" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br></div>