我们如何在JBoss Rules中的.drl文件之间共享单独的规则? [英] How can we share individual rules between .drl files in JBoss Rules?

查看:121
本文介绍了我们如何在JBoss Rules中的.drl文件之间共享单独的规则?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用 JBoss规则(又名Drools),并且有多个 .drl 文件,每个文件包含几个规则.有没有一种方法可以避免文件之间的重复,以便我们可以定义可用于多个 .drl 文件的通用规则?

We are using JBoss Rules (a.k.a. Drools) and have several .drl files that each contain several rules. Is there a way to avoid duplication between files, so that we can define common rules that are available to more than one .drl file?

不幸的是,似乎没有任何 include 或模块工具.

Unfortunately, there does not seem to be any kind of include or module facility.

推荐答案

无法从.drl文件中包含来自另一个.drl文件的规则.

There is no way of including rules from another .drl file from within a .drl file.

不过,您可以将两个.drl文件添加到相同的ruleBase中,它们将像在同一文件中一样工作.

You can however add two .drl files to the same ruleBase and they will work as if they were in the same file.

PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "common.drl" ) ) );
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "rules1.drl" ) ) );
RuleBase ruleBase  = RuleBaseFactory.newRuleBase();
ruleBase.addPackage( builder.getPackage()  );

这篇关于我们如何在JBoss Rules中的.drl文件之间共享单独的规则?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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