Drools全局变量是否有会话限制? [英] Are Drools global variables session-bound?

查看:88
本文介绍了Drools全局变量是否有会话限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Drools中声明和使用全局变量时,在会话关闭后,全局变量是否完全绑定到该会话上?

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?

是否有某种方法可以将数据存储在Drools内存中,而每次会话都可以随时访问它们而无需每次都重新加载它们?

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?

推荐答案

DRL全局变量是POJO,只要存在至少一个对其的引用,便会存在。在setGlobal之后,一个会话保留一个(附加)引用,该引用可通过DRL编译器提供的全局名称进行访问。如果会话被丢弃,该引用将消失。

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.

Drools记忆一词没有意义。有一个会话的工作记忆,它是用于插入POJO成为事实的POJO的容器;如果会话被丢弃,则这些引用将被丢弃。有全局变量。而且在DRL代码中,您可以访问已导入的所有内容,包括Java类中的(公共)静态变量。

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.

这篇关于Drools全局变量是否有会话限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆