I have a rule which accepts Map()
as a fact and then sets lots of elements to this map. I want to be able to use this map somewhere else when executing other rules. I read about globals in Drools but seems like they should not be used for this purpose. Right now I keep this map as private property in Java class, so that it can keep all data in web application context, but this increases my memory footprint. I know it might sound bizarre but is there any analogy in Drools rules to Java static fields?
Thanks in advance!
can you explain a little bit more about what is your rule trying to achieve? most of the times you should reformulate the rules in order to fit your needs. A rule that filters a Map() require an instance of java.util.Map to be inserted inside the knowledge session. If you add a Map as a global your rules will not be able to directly filter a Map(). I usually recommend to use more structured facts/objects to write rules instead of generic structures.
Remember that if you insert a java.util.Map instance to the session, that Map will be available for all the rules that filters the Map() object type.
Hope it helps, if you can provide more information we will be able to help further.
Cheers