use of org.drools.KnowledgeBaseConfiguration in project jBPM5-Developer-Guide by Salaboy.
the class EventsTesterJFrame method createKnowledgeSession.
private StatefulKnowledgeSession createKnowledgeSession() {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(new ClassPathResource("simpleEventAnalysis.drl"), ResourceType.DRL);
if (kbuilder.hasErrors()) {
for (KnowledgeBuilderError error : kbuilder.getErrors()) {
System.out.println(" >>> Error:" + error.getMessage() + "\n");
}
throw new IllegalStateException(">>> Knowledge couldn't be parsed! ");
}
KnowledgeBaseConfiguration config = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
config.setOption(EventProcessingOption.STREAM);
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(config);
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
KnowledgeSessionConfiguration sessionConfig = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
sessionConfig.setOption(ClockTypeOption.get("realtime"));
return kbase.newStatefulKnowledgeSession(sessionConfig, null);
}
Aggregations