Are Drools global variables session-bound?

江枫思渺然 提交于 2019-12-25 04:07:03

问题


When declaring and using global variables within Drools, are globals entirely bound to the session in the sense that once the session is closed, the globals are disposed of too?

Is there some way of storing data in drools memory that can be accessed by numerous sessions at any one time without needing it to be reloaded each time?


回答1:


A DRL global is a POJO, which exists as long as there exists at least one reference to it. After setGlobal, a session keeps one (additional) reference, which is made accessible via the global's name, courtesy of the DRL compiler. If the session is disposed this reference evaporates.

The term "Drools memory" has no significance. There is a session's Working Memory, which is a container for POJOs which have been inserted to become facts; if the session is disposed, these references are discarded. There is the globals. And in DRL code you can access everything that has been imported, including (public) static variables in Java classes.



来源:https://stackoverflow.com/questions/28201629/are-drools-global-variables-session-bound

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!