[rules-users] how to check if a global has been declared in a rule

Esteban Aliverti esteban.aliverti at gmail.com
Wed Feb 9 10:48:36 EST 2011


What about ksession.getGlobals().get("obj")?

Best Regards,

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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


On Wed, Feb 9, 2011 at 12:24 PM, gs76pl <gstasica at pacemetrics.com> wrote:

>
> hi,
>
> is it possible to check if a rule has been defined with a global as below?
>
> global MyObject obj;
>
> rule
> when
> then
>
> Basically, i'm running below code:
> ksession = kbase.newStatefulKnowledgeSession();
> ksession.setGlobal("obj", new MyObject());
>
> but if a rule doesn't have global definition my code throws an exception.
> What i'd like to do is something like
> ksession.getGlobal('"obj") or ksession.checkGlobalExist('"obj").
> Unfortunately the first method doesn't work as it doesn't check if a global
> has been declared in a rule
> --
> View this message in context:
> http://drools-java-rules-engine.46999.n3.nabble.com/how-to-check-if-a-global-has-been-declared-in-a-rule-tp2459143p2459143.html
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110209/23e33ff1/attachment.html 


More information about the rules-users mailing list