[rules-users] Setting unused globals on a session

Vincent LEGENDRE vincent.legendre at eurodecision.com
Thu Jun 21 17:37:15 EDT 2012


I am not sure to have fully understood you last requirement, nor if you set the global inside or outside the rules.
Anyway, I see these options :
   - declare your globals for all packages, but it seems that this is not what you want
   - enclose the global setting in a try...catch and just forget the thrown exception. It does not harm the session at all. 
   - use kSession.getGlobals() that returns all the globals' ID, and only set if the ID is there (but it is the same thing done in the setGlobal(String) anyway). I am using this last way to set 'as much globals as I can', according to their names/types and my 'config' POJO attributes names (something close to spring auto-injection idea).

Hope this helps

----- Mail original -----
De: "gqmulligan" <gqmulligan at gmail.com>
À: rules-users at lists.jboss.org
Envoyé: Jeudi 21 Juin 2012 21:46:37
Objet: [rules-users] Setting unused globals on a session

I save many different knowledge packages for different accounts to a
database.  Most accounts use a particular service to pull data from the
database but not all of them.  Because of this I wanted to set this service
as a global on the session.

However, because not all accounts use the service I get an exception when I
try to set it on the session for an account that does not use the service
anywhere in its rules.  Does an exception really need to be thrown in this
case?  

Also,  do I have any options to work around this exception without having
some sort of "master" rule that is automatically put into all accounts and
declares all globals?  The service is being pulled from a bean so I would
like to stay away from having to find it by name and keep to injecting any
global services if possible.

Thanks.

--
View this message in context: http://drools.46999.n3.nabble.com/Setting-unused-globals-on-a-session-tp4018146.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



More information about the rules-users mailing list