[rules-users] Initialize Global
java_user_
jkraemer at cs.tufts.edu
Tue Oct 30 14:59:21 EDT 2007
Yes, I used the conditional eval(objectList == null)
The global keeps getting destroyed after each execution. I am using a
stateful rule session. I was hoping the global could be reused for each
execution without having to re-init.
I was able to do this in Jess by instantiating the global without having to
use a rule. Then I was able to use the same list each execution of my
stateful session without having to recreate the list. The Jess list is an
internal Jess object and not a Java ArrayList.
Jess Code to declare and initialize a global list:
(defglobal ?*objectList* =
(create$
(new String "s0")
(new String "s1")
)
)
Anstis, Michael (M.) wrote:
>
> Did you try Kris's suggested LHS?
>
>> You can test whether the global is null using eval( objectList == null )
>> in the LHS of the rule.
>
> This should provide the condition you request and prevent the rule from
> firing after the global has been initialised.
>
> -----Original Message-----
> From: rules-users-bounces at lists.jboss.org
> [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of java_user_
> Sent: 30 October 2007 16:06
> To: rules-users at lists.jboss.org
> Subject: Re: [rules-users] Initialize Global
>
>
> Hi Kris,
>
> I am using a JSR94 stateful session. My design is to initialize the
> global
> list once and reuse it within the same session.
>
> The init-global rule is being executed each execution because there is no
> conditional statement. Can I disable the rule for future executions?
>
> Thanks
>
>
>
> Kris Verlaenen wrote:
>>
>>> That initialized my global but the rule still runs every execution. Can
>>> I
>>> disable the rule after the first execution?
>> What do you mean by "every execution". A rule should only be executed
>> once,
>> unless it gets reactivated (which should not be the case in this
>> situation).
>>
>>> I would like to use (if (objectList==null)). My list is not immutable.
>>> Can
>>> I make a similar rule for the LHS?
>> You can test whether the global is null using eval( objectList == null )
>> in
>> the LHS of the rule.
>>
>> Kris
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>
> --
> View this message in context:
> http://www.nabble.com/Initialize-Global-tf4685186.html#a13491481
> Sent from the drools - user mailing list archive at Nabble.com.
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
--
View this message in context: http://www.nabble.com/Initialize-Global-tf4685186.html#a13493442
Sent from the drools - user mailing list archive at Nabble.com.
More information about the rules-users
mailing list