[rules-users] Global variables not retaining changes.

Justin King justin.matthew.king at gmail.com
Sun Sep 6 20:45:09 EDT 2009


Some extra information. The global is of type Integer. Now if I understand
correctly, using "+" on an Integer object is the same as "integer = new
Integer(integer.getValue() + 1)". It seems calling new on a global  inside
the rule file causes the problem, because if I define my own integer wrapper
class with a simple set method and use this instead, the problem goes away.
Anyone have any suggestions???

On Mon, Sep 7, 2009 at 9:53 AM, Justin King
<justin.matthew.king at gmail.com>wrote:

> Hi,
>
> I currently have a drl file containing two globals, both objects. I
> initialize these objects and populate the globals via
> StatefulKnoweledgeSessions setGlobal("string", obj) method. During execution
> some of the rules update values in these objects (I mostly using them for
> keeping a count of the number of times a certain condition has been met). I
> wish to periodically get the current value of the globals for use in other
> parts of the program, but even though I know for a fact they have been
> updated by some rule executions they are always the same value as when I
> originally initialized them. Can anyone tell me why this is? And if its
> possible to make them retain their value?
>
> Cheers,
>
> Justin
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20090907/ad83f4ac/attachment.html 


More information about the rules-users mailing list