If the "global" is both modified by rules and investigated by rules: then it's not a global but a singleton fact.
You can use a global in a condition, but only if the data obtained from the global is constant over time. I think that your "container" ought to be a fact. -W 2011/7/29 Matthew Erler <[email protected]> > I'm using Drool 5. I reviewed globals and it looks like it might be > appropriate for my situation. I find plenty of documentation on how to use > a global in a consequence, but none on how to use a global in a condition. > Do you know if it's possible to use a global in a condition? My situation > is that I need to check a container class to see if the container is filled, > if not then fill the container (the condition would actually be more > elaborate and include facts but I'm omitting them for the sake of brevity). > The DRL file would look something like this (the example doesn't work of > course): > > > global com.example.Container globalContainer; > > rule "container full rule" > when > globalContainer.getContentsFlag() == false > then > globalContainer.fill(new ContainerContents()); > globalContainer.setContentsFlag(true); > > > --- On *Fri, 7/29/11, Esteban Aliverti <[email protected]>*wrote: > > > From: Esteban Aliverti <[email protected]> > Subject: Re: [rules-users] How to add application data via > StatefulKnowledgeSession > To: "Rules Users List" <[email protected]> > Date: Friday, July 29, 2011, 3:51 AM > > Which version of drools are you using? The document you pointed out seems a > little bit old. > Since Drools 5, you can use globals to use application's data in your DRLs. > If you are using Drools 5 or higher, I suggest you to read the > documentation about globals. > > Best Regards, > > XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > > Esteban Aliverti > - Developer @ http://www.plugtree.com > - Blog @ http://ilesteban.wordpress.com > > > 2011/7/28 Matthew Erler > <[email protected]<http://mc/[email protected]> > > > > Can someone please show me an example where application data is added to > workingMemory as described here: > http://docs.codehaus.org/display/DROOLS/Application+Data using > StatefulKnowledgeSession? > I have a need to populate an object from a rules file and I don't want that > object itself to be treated as a rule. All the examples I can find refer > to > the use of ruleBase to get workingMemory. My code utilizes > StatefulKnowledgeSession to fire rules and I don't see how to get ruleBase > or workingMemory from it. Thanks. > > _______________________________________________ > rules-users mailing list > [email protected]<http://mc/[email protected]> > https://lists.jboss.org/mailman/listinfo/rules-users > > > > -----Inline Attachment Follows----- > > _______________________________________________ > rules-users mailing list > [email protected]<http://mc/[email protected]> > https://lists.jboss.org/mailman/listinfo/rules-users > > > _______________________________________________ > rules-users mailing list > [email protected] > https://lists.jboss.org/mailman/listinfo/rules-users > >
_______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
