当前位置:网站首页>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 :

边栏推荐
- C#时间相关操作
- Gbase 8C core technology
- Drools(5):Drools高级语法
- Automatically generate UML sequence diagram according to text (draw.io format)
- Codeforces Round #804 (Div. 2)(5/5)
- MySQL index failure and solution practice
- ZnS-DNA QDs近红外硫化锌ZnS量子点改性脱氧核糖核酸DNA|DNA修饰ZnS量子点
- Pan Aimin, chairman of instruction set, attended the 2022 ecug con to speak for China's technical forces
- Watermelon book chapter 3 - linear model learning notes
- Analysis of pix2pix principle
猜你喜欢

Music website management system based on SSM

How MySQL executes query statements

VIVO应用市场APP上架总结

A Competitive Swarm Optimizer for Large Scale Optimization

从技术原理看元宇宙的可能性:Omniverse如何“造”火星

DNA modified zinc oxide | DNA modified gold nanoparticles | DNA coupled modified carbon nanomaterials

(转帖)eureka、consul、nacos的对比2

Basic statement of MySQL (1) - add, delete, modify and query

Two ways of multi GPU training of pytorch

Derivative, partial derivative and gradient
随机推荐
Student status management system based on SSM
二叉树--天然的查找语义(1)基础篇
CdS quantum dots modified DNA | CDs DNA QDs | near infrared CdS quantum dots coupled DNA specification information
Vscode creates golang development environment and debug unit test of golang
Express framework
pytorch笔记:TD3
Basic statement of MySQL (1) - add, delete, modify and query
Day012 application of one-dimensional array
基于SSM医院预约管理系统
Interpretation of deepsort source code (IV)
"Weilai Cup" 2022 Niuke summer multi school training camp 1
ESP8266(ESP-12F) 第三方库使用 -- SparkFun_APDS9960 (手势识别)
泛型 -- 学会它,好处多多
Reflection on pytorch back propagation
PNA polypeptide PNA TPP | GLT ala ala Pro Leu PNA | suc ala Pro PNA | suc AAPL PNA | suc AAPM PNA
内部类--看这篇就懂啦~
Digital image processing -- Chapter 3 gray scale transformation and spatial filtering
AI: play games in your spare time - earn it a small goal - [Alibaba security × ICDM 2022] large scale e-commerce map of risk commodity inspection competition
Codeforces Round #809 (Div. 2)(6/6)(Kruskal重构树)
2021 interview question of php+go for Zhongda factory (1)