标签:
Drools6的代码包中不再提供类似Drools5的编程方式,如果还需要使用Drools5的方式,可以手工编译一下源码包中的knowledge-api-legacy5-adapter项目,将这个项目的jar加入到路径中即可兼容以前的编程代码。
Drools5中传统的JAVA调用方式在Drools6中已经完全被放弃了,下面对比一下:
Drools5代码
KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder();
builder.add(ResourceFactory.newClassPathResource("Approve1.drl", Approve1.class), ResourceType.DRL);
KnowledgeBase base = KnowledgeBaseFactory.newKnowledgeBase();
base.addKnowledgePackages(builder.getKnowledgePackages());
StatefulKnowledgeSession ksession = base.newStatefulKnowledgeSession();
for (int i=0;i<list.size();i++) { ksession.insert(list.get(i)); }
Droosl6代码
KieServices ks = KieServices.Factory.get(); KieContainer kc = ks.getKieClasspathContainer(); KieSession ksession = kc.newKieSession("HelloWorldKS"); for (int i=0;i<list.size();i++) { ksession.insert(list.get(i)); }
标签:
原文地址:http://www.cnblogs.com/dindin2046/p/4507511.html