0

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!

azec-pdx
  • 4,790
  • 6
  • 56
  • 87

1 Answers1

0

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

salaboy
  • 4,123
  • 1
  • 14
  • 15
  • I have XLS decision table (3000+ rules), where someone wrote rules are in the role of data container and have only trivial logic(setting values to domain object).This causes PermGen exceptions so I had to pull them out of there. Now I have put this map in java and pass it as fact, and populate map only when first rule fires. So this map is on my heap space of deployed application. Is there better solution of populating this map and sharing among rules? Note: This is just temporary solution, all this data will be removed from rules at one point, but I had to work arround this PermGen issue. – azec-pdx Dec 05 '11 at 08:19