当前位置:网站首页>Drools (5): drools advanced syntax
Drools (5): drools advanced syntax
2022-07-27 07:14:00 【Undead bird. Alexander. Wolf cub】
Advanced Grammar
| keyword | describe |
package | Package name , Limited to logical management , Same as ⼀ The query or function under the package name can be called directly ⽤ |
import | ⽤ Yu Dao ⼊ Class or static ⽅ Law |
global | Global variables |
function | ⾃ Defined function |
query | Inquire about |
rule end | Regular form |
global Global variables
Global variables ,⼀ like ⽤ Act and hold ⾏ The result data after the rule is returned or a specific service is called ⽤ etc. , Such as ⼀ Examples of email services , In tune ⽤ Rule engine integration code , obtain emailService object , Then set it to ⼯ As in memory .
The grammatical structure is :global object type Object name
Example :
package rules
import java.util.List;
global java.util.List myGlobalList;
// If in the rule ⽂ Make... In the piece ⽤ It's a global variable , Then it must be regulated Then set the global variable value in the engine
rule "global_rule1"
when
eval( true )
then
myGlobalList.add( "Hello World" );
// System.out.println("global_rule1 is execution...");
end
rule "global_rule2"
when
eval( true )
then
System.out.println("myGlobalList The number of elements in the set :"+myGlobalList.size());
System.out.println("global_rule2 is execution...");
endtest :
@Test
public void test13() throws InterruptedException {
KieServices kieServices = KieServices.Factory.get();
KieContainer kieClasspathContainer = kieServices.getKieClasspathContainer();
KieSession kieSession = kieClasspathContainer.newKieSession();
List list = new ArrayList();
Set global variables , Name and type must match rules ⽂ The global variable name defined in the file corresponds to
kieSession.setGlobal("myGlobalList", list);
// Activate rule engine , If the match is successful, execute ⾏ The rules
kieSession.fireAllRules();
kieSession.dispose();
System.out.println("list.size():" + list.size());
}
test result :

边栏推荐
- 2021 interview questions for php+go of Zhongda factory (2)
- word-wrap:break-word 换行在各浏览器兼容的问题
- Automatically generate UML sequence diagram according to text (draw.io format)
- Book borrowing management system based on SSM
- Digital image processing -- Chapter 3 gray scale transformation and spatial filtering
- How to implement Devops with automation tools | including low code and Devops application practice
- DNA research experiment application | cyclodextrin modified nucleic acid cd-rna/dna | cyclodextrin nucleic acid probe / quantum dot nucleic acid probe
- Leetcode series (I): buying and selling stocks
- 网易云信亮相 GIAC 全球互联网架构大会,解密新一代音视频架构在元宇宙场景的实践...
- Interpretation of deepsort source code (6)
猜你喜欢

jest单测样式问题【identity-obj-proxy】npm包

Dajiang livox customized format custommsg format conversion pointcloud2

Analysis of pix2pix principle

A Competitive Swarm Optimizer for Large Scale Optimization

Digital image processing Chapter 1 Introduction

Leetcode series (I): buying and selling stocks

DNA coupled PbSe quantum dots | near infrared lead selenide PbSe quantum dots modified DNA | PbSe DNA QDs

Qi Yue: thiol modified oligodna | DNA modified cdte/cds core-shell quantum dots | DNA coupled indium arsenide InAs quantum dots InAs DNA QDs

Book borrowing management system based on SSM

指令集董事长潘爱民出席2022 ECUG Con,为中国技术力量发声
随机推荐
Dajiang livox customized format custommsg format conversion pointcloud2
(转帖)eureka、consul、nacos的对比1
基于SSM学生成绩管理系统
Music website management system based on SSM
Interpretation of deepsort source code (6)
把Excel转换成CSV/CSV UTF-8
Gbase 8C core technology
2021 interview questions for php+go of Zhongda factory (2)
jest单测样式问题【identity-obj-proxy】npm包
用typescript实现排序-递增
DNA修饰贵金属纳米颗粒|脱氧核糖核酸DNA修饰纳米金(科研级)
Student status management system based on SSM
Digital image processing - Chapter 6 color image processing
How MySQL executes query statements
The vscode run command reported an error: the mark "&" is not a valid statement separator in this version.
TS learning (VIII): classes in TS
Golang encapsulates the packages involved in MySQL and the differences between sqlx and Gorm
Interpretation of deepsort source code (II)
DNA (deoxyribonucleic acid) supply | carbon nanotube nucleic acid loaded dna/rna material | dna/rna nucleic acid modified magnetic nanoparticles
DNA modified noble metal nanoparticles | DNA modified gold nanoparticles (scientific research level)