Search in sources :

Example 6 with KnowledgeBaseConfiguration

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);
}
Also used : KnowledgeBuilderError(org.drools.builder.KnowledgeBuilderError) KnowledgeBuilder(org.drools.builder.KnowledgeBuilder) KnowledgeBase(org.drools.KnowledgeBase) KnowledgeBaseConfiguration(org.drools.KnowledgeBaseConfiguration) KnowledgeSessionConfiguration(org.drools.runtime.KnowledgeSessionConfiguration) ClassPathResource(org.drools.io.impl.ClassPathResource)

Aggregations

KnowledgeBase (org.drools.KnowledgeBase)6 KnowledgeBaseConfiguration (org.drools.KnowledgeBaseConfiguration)6 KnowledgeBuilder (org.drools.builder.KnowledgeBuilder)6 KnowledgeBuilderError (org.drools.builder.KnowledgeBuilderError)6 ClassPathResource (org.drools.io.impl.ClassPathResource)6 StatefulKnowledgeSession (org.drools.runtime.StatefulKnowledgeSession)4 KnowledgeSessionConfiguration (org.drools.runtime.KnowledgeSessionConfiguration)3 WorkingMemory (org.drools.WorkingMemory)2 KnowledgeBuilderErrors (org.drools.builder.KnowledgeBuilderErrors)2 HornetQHTWorkItemHandler (org.jbpm.process.workitem.wsht.HornetQHTWorkItemHandler)2 DebugAgendaEventListener (org.drools.event.rule.DebugAgendaEventListener)1 QueryResultsRow (org.drools.runtime.rule.QueryResultsRow)1 Task (org.jbpm.task.Task)1 User (org.jbpm.task.User)1 TaskSummary (org.jbpm.task.query.TaskSummary)1 Test (org.junit.Test)1