JBoss Drools - how to get data (facts) from java to DRL

时间:2018-05-28 18:41:19

标签: jboss drools

How can I get fact definied by user in GUI and insert it to DRL?

For example: The user has chosen black car in GUI (JavaFX), and now I want to use that fact in DRL code. How to send that info about black car to DRL? Should i use POJO?

1 个答案:

答案 0 :(得分:0)

如果要执行已在DRL文件中编写的规则,则必须创建POJO并使用KieSession执行规则。例如,

val pojo = new POJO('POJO arguments') 
val kieServices = KieServices.Factory.get()
val kieContainer = kieServices.newKieClasspathContainer()
val kieSession = kContainer.newKieSession()
kieSession.insert(pojo)
kieSession.fireAllRules()

阅读this文档。您可以获取所有drool-API示例here