[英]How can I set global variable in drools using drools-spring and use same in DRL file
基本上,我想将类引用存储为spring服务类的全局变量,并在DRL文件中使用相同的引用来访问全局引用的方法和属性。
Inside your service class use below code: 在服务类内部,使用以下代码:
StatelessKnowledgeSession knowledgeSession;
CustomClass reference;
knowledgeSession.setGlobal("global1", reference);
knowledgeSession.execute(fact);
Inside DRL file 内部DRL文件
import CustomClass;
global CustomClass global1
Use reference inside any rule. 在任何规则内使用引用。
you have to set the object ref into the kieSession as below 您必须将对象ref设置到kieSession中,如下所示
kieSession.setGlobal("serviceName", serviceRef);
and in your drools file import the global reference 并在您的drools文件中导入全局参考
global com.example.Service serviceName
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.