- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是流口水的新手。我已经执行了 drl 文件中的规则。这是我的 drl 文件。
rule "Person is 21"
salience 1
when
$person : Person(age>=21,car.equalsIgnoreCase("duster"))
then
System.out.println($person.name);
end
这是我的模型文件
public class Person
{
private String name;
private int age;
private String car;
public Person()
{
}
public Person(String name, int age,String car)
{
this.name = name;
this.age = age;
this.car=car;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public int getAge()
{
return age;
}
public void setAge(int age)
{
this.age = age;
}
public String getCar() {
return car;
}
public void setCar(String car) {
this.car = car;
}
}
这是我的规则运行器方法代码,它将规则和事实作为参数并构建 kie session 并触发规则
public void runRules(String[] rules, Object[] facts)
{
KieServices kieServices = KieServices.Factory.get();
KieResources kieResources = kieServices.getResources();
KieFileSystem kieFileSystem = kieServices.newKieFileSystem();
KieRepository kieRepository = kieServices.getRepository();
for(String ruleFile : rules)
{
Resource resource = kieResources.newClassPathResource(ruleFile);
// path has to start with src/main/resources
// append it with the package from the rule
kieFileSystem.write( resource);
}
KieBuilder kb = kieServices.newKieBuilder(kieFileSystem);
kb.buildAll();
if (kb.getResults().hasMessages(Level.ERROR))
{
throw new RuntimeException("Build Errors:\n" + kb.getResults().toString());
}
KieContainer kContainer = kieServices.newKieContainer(kieRepository.getDefaultReleaseId());
KieSession kSession = kContainer.newKieSession();
for (Object fact : facts)
{
kSession.insert(fact);
}
kSession.fireAllRules();
}
当我使用dslr文件时我应该做什么改变(下面是dslr文件)
rule "My First Rule"
when
Person is at least 21 and car is "duster"
then
Log : "hello world"
end
在 Eclipse 中,从 dslr 文件生成的 drl 文件是正确的。下面是dsl扩展器生成的drl文件中的规则(我可以在eclipse中的drl查看器中看到上面的dslr)
rule "My First Rule"
when
i: Person(age > 21, car=="duster")
then
System.out.println("hello world");
end
我尝试从我的 drl 文件运行相同的规则,并且执行成功
我面临的问题是我尝试将 DSL 和 DSLR 文件作为参数传递给规则资源
Resource resource = kieResources.newClassPathResource("MyDslr.dslr","dslExample.dsl");
我收到以下异常
Exception in thread "main" java.lang.RuntimeException: Build Errors:
Error Messages:
Message [id=1, level=ERROR, path=MyDslr.dslr, line=17, column=0
text=[17] No mapping entries for expanding: Person is at least 21 and
car is "duster"]
Message [id=2, level=ERROR, path=MyDslr.dslr, line=17, column=0
text=[17] Unable to expand: Person is at least 21 and car is "duster"]
Message [id=3, level=ERROR, path=MyDslr.dslr, line=19, column=0
text=[19] No mapping entries for expanding: Log : "hello world"]
Message [id=4, level=ERROR, path=MyDslr.dslr, line=19, column=0
text=[19] Unable to expand: Log : "hello world"]
Message [id=5, level=ERROR, path=MyDslr.dslr, line=17, column=0
text=[ERR 102] Line 17:15 mismatched input 'is' in rule "My First Rule"]
---
Warning Messages:
---
Info Messages:
at controller.RuleRunner.runRules(RuleRunner.java:43)
at mainPackage.Main.main(Main.java:21)
这是我的 dsl 文件在 eclipse 中的样子(它正在 drl 中转换 dslr,并且转换后的规则在直接从 drl 文件 rul 时没有给出异常(exception))
请帮帮我。如果有如何使用 kie api 和 dslr 和 dsl 文件触发规则的示例,那么这也会有所帮助。
谢谢
最佳答案
来电
... = kieResources.newClassPathResource("MyDslr.dslr","dslExample.dsl")
不可能正确 - 比较此方法的 Javadoc:第二个参数应该指示编码。
但是,这一系列语句是有效的:
FileInputStream fis1 = new FileInputStream( "simple/simple.dsl" );
kfs.write( "src/main/resources/simple.dsl",
kieServices.getResources().newInputStreamResource( fis1 ) );
FileInputStream fis2 = new FileInputStream( "simple/simple.dslr" );
kfs.write( "src/main/resources/simple.dslr",
kieServices.getResources().newInputStreamResource( fis2 ) );
KieBuilder kieBuilder = kieServices.newKieBuilder( kfs ).buildAll();
您应该使用路径名数组、DSL 以及 DSLR 来调用方法 runRules(String[]rules, Object[]facts)
。
关于java - 使用 dsl 和 dslr 文件时如何构建 Kie session ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32063120/
我是新来的 jBPM . 我仅通过 Business Central (KIE Workbench) 开发和部署了一个业务流程,并且运行良好。 我没有直接使用 Kie Server。 我想知道 之间的
我想知道jbpm、kie server和kie workbench有什么区别。我现在正在学习 jbpm 教程,所以我下载了完整的安装程序。但是,我读到: 1. jbpm 可以分发为不同的jar。 2.
我正在尝试构建一个通过注入(inject)集成 kie (drools 6) 的 Web (spring-mvc) 应用程序。我使用 kie workbench 创建工作流程,进行编译和部署。我已在项
我正在尝试为 apache-tomcat-8.5.20 安装 kie-server。 Tomcat 正在运行,但 kie-workbench 没有启动。它抛出以下错误: SLF4J: Failed t
我有一个 Maven Java 项目,它构建正确,但在 pom.xml 中添加以下依赖项后: org.kie kie-api 6.4.0.Final 我收到以下错误: Faile
我将 Play 2.2.3 与 Java 和 sbt.version=0.13.5 结合使用。 当我运行play cleancompile时,我可以看到: [success] Total time:
我们正在将业务中心服务器从 7.23.0 升级到 7.28.0。我们注意到我们的 kie 服务器无法再通过 websocket 连接到业务中心: 服务器日志: Oct 28 12:56:43 busi
在任何人开始否决这个问题之前,我尝试使用“kie”、“project”、“where”、“location”、“workbench”、“pom”这些词的所有组合进行谷歌搜索、“来源”、"file",我
我需要 KIE API 方面的帮助。需要知道它是什么,是否有任何教程可用于使用 Drools KIE。 kie 是 drools-6.x 的一部分吗?如果它是 drools-6.x 的一部分,那么
我正在尝试设置 kie 执行服务 (kie-server-services-6.2.0) 以供 kie-drools-wb-webapp-6.2.0 提供,当我尝试通过以下 webapp url执行服
从哪里可以找到最新稳定版本(6.3.0.Final)的 Kie-Execution Server 源代码? 我找到了以下网站,其中包含 6.2.0.Final 的源代码,但我没有找到任何可以下载 6.
我尝试从我通过 KIE Workbench 创建的项目中获取 kieContainer。 String url = "http://dev.dsack.local:8080/kie-wb/ma
我有以下 POJO: public class Transaction { @Id private long id; private String organisationId
我正在使用带有 spring 集成的 Drools 6.2.0。 spring-context.xml 文件如下:
我已经设置了 KIE 工作台,一切运行良好。我无法理解如何管理生产环境中的部署。我必须做两件事。 如何在开发和生产环境中管理用户/角色/组。我在开发环境中有用户/角色/组和项目设置。有没有更好的方法将
我已经使用 Wildify10 & kie-drools-wb-7.0.0.Final-wildfly10.war & kie-server-7.0.0.Final-ee7.war 来部署和使用 KI
我创建了一个示例业务流程来模拟我的组织用例的需求。该用例涉及员工、房间、部门等对象。我使用 KIE 工作台将这些实体创建为数据模型。 谁能告诉我如何持久保存这些 POJO/实体?如何配置jBPM引擎以
我正在尝试将我的 KIE Workbench 6.1.FINAL 部署与使用 Drools 6.1.FINAL 的简单应用程序集成。我使用以下代码: String url = "http://loca
本文整理了Java中org.kie.api.runtime.process.WorkItemHandler类的一些代码示例,展示了WorkItemHandler类的具体用法。这些代码示例主要来源于Gi
本文整理了Java中org.kie.api.definition.process.WorkflowProcess类的一些代码示例,展示了WorkflowProcess类的具体用法。这些代码示例主要来源
我是一名优秀的程序员,十分优秀!