KnowledgeSessionConfiguration config = KnowledgeBaseFactory.newKnowledgeSessionConfiguration(sessionconfigproperties);
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); }
/** * Creates a new KnowledgeSessionConfiguration given the specified component implementation config. * @param cic the component implementation config * @return the config */ public static KnowledgeSessionConfiguration getSessionConfiguration(ComponentImplementationConfig cic) { KnowledgeSessionConfiguration ksessionConfig = KnowledgeBaseFactory.newKnowledgeSessionConfiguration(getProperties(cic)); ClockType clock = cic.getModel().getClock(); if (clock != null) { switch (clock) { case REALTIME: ksessionConfig.setOption(ClockTypeOption.get(org.drools.ClockType.REALTIME_CLOCK.getId())); break; case PSEUDO: ksessionConfig.setOption(ClockTypeOption.get(org.drools.ClockType.PSEUDO_CLOCK.getId())); break; } } return ksessionConfig; }
@Test public void testUsingSessionClock() { //BZ-1058687 String str = "global java.util.List list\n" + "\n" + "rule R\n" + "when\n" + " $i : Integer( ) from list\n" + "then\n" + "end"; KnowledgeBase kbase = loadKnowledgeBaseFromString(str); KnowledgeSessionConfiguration ksconfig = KnowledgeBaseFactory.newKnowledgeSessionConfiguration(); ksconfig.setOption(ClockTypeOption.get("pseudo")); StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(ksconfig, null); // compilation fails on Java 6 SessionPseudoClock clock = ksession.getSessionClock(); }
ClassNotFoundException { if ( config == null ) { config = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
ClassNotFoundException { if ( config == null ) { config = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();