我是 Drools 和 Guvnor 的新手。我们已经创建了 DRL 文件并在 Guvnor 中加载,我们构建了包。它产生了一个.pkg
文件。我们从 Guvnor 下载此.pkg
文件并将其用于我们的不同项目。现在我正在尝试查看.pkg
文件中的内容,但我不知道如何打开它。
2 回答
没有工具(我知道)用于打开 Drools pkg 文件并检查其内容。根据您要实现的目标,可能的解决方案是以编程方式从该 pkg 创建一个 Kiebase(或 kbase)并以编程方式检查其内容。
顺便说一句,您想在该文件中找到什么?
希望能帮助到你,
The following code examines a knowledge base and will write out the names of all the packages that were loaded into it and the names of the rules in those packages. There's probably a bit more info that can be extracted, but I have never found the need. The only thing you won't get is the source code of the rules. But going by your explanation, that is available in Guvnor.
/**
* Return a string containing the packages used to build the knowledge base.
*/
public static String knowledgeBaseDetails(KieBase kbase) {
if (kbase == null) {
return "Knowledge Base is null.";
} else {
StringBuilder sb = new StringBuilder(
"Knowledge base built from the following packages:");
Collection<KiePackage> packages = kbase
.getKiePackages();
for (KiePackage kp : packages) {
sb.append("\n Package: [" + kp.getName() + "]");
for (Rule rule : kp.getRules()) {
sb.append("\n Rule: [" + rule.getName() + "]");
}
}
return sb.toString();
}
}
It's almost the same for Drools 5 and 6. Generally for the earlier versions of Drools, just change Kie
to Knowledge
.