本文整理汇总了Java中org.kie.api.runtime.conf.ClockTypeOption类的典型用法代码示例。如果您正苦于以下问题:Java ClockTypeOption类的具体用法?Java ClockTypeOption怎么用?Java ClockTypeOption使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClockTypeOption类属于org.kie.api.runtime.conf包,在下文中一共展示了ClockTypeOption类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: loadDrools
import org.kie.api.runtime.conf.ClockTypeOption; //导入依赖的package包/类
private void loadDrools() {
try {
logger.info("Initializing Drools rule engine");
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
addDrls(kbuilder);
KieSessionConfiguration config = KieServices.Factory.get().newKieSessionConfiguration();
config.setOption(ClockTypeOption.get("pseudo"));
logger.debug("Compiling rules");
kSession = kbuilder.newKieBase().newKieSession(config, null);
homeioSessionClock = new HomeioSessionClock(kSession.getSessionClock());
initGlobals();
droolsInitialized = true;
logger.debug("Successfully initialized Drools rule engine");
} catch (Exception e) {
logger.error("Exiting because of an exception during the Drools initialization ", e);
new RuntimeException("Exiting because of an exception during the Drools initialization");
}
}
开发者ID:IncQueryLabs,项目名称:smarthome-cep-demonstrator,代码行数:26,代码来源:DroolsEventBusClient.java
示例2: start
import org.kie.api.runtime.conf.ClockTypeOption; //导入依赖的package包/类
@PostConstruct
public void start() {
// FIXME: exclude *.csv files from being treated as decision table
final KieSessionConfiguration config = kieServices().newKieSessionConfiguration();
config.setOption(ClockTypeOption.get("realtime"));
// FIXME: exclude *.csv files from being treated as decision table
kieSession = kieBase().newKieSession(config, null);
kieSession.setGlobal("log", log);
kieSession.setGlobal("env", env);
kieSession.setGlobal("producer", producer);
kieSession.setGlobal("storyRepo", storyRepo);
kieSession.setGlobal("quranSvc", quranSvc);
kieSession.setGlobal("literalRepo", literalRepo);
kieSession.setGlobal("quranChapterRepo", quranChapterRepo);
kieSession.setGlobal("quranVerseRepo", quranVerseRepo);
// kieSession.addEventListener(new DebugAgendaEventListener());
// kieSession.addEventListener(new DebugRuleRuntimeEventListener());
executor().submit(() -> {
log.info("Starting {}", kieSession);
kieSession.fireUntilHalt();
log.info("{} halted", kieSession);
});
}
开发者ID:lumenrobot,项目名称:lumen,代码行数:24,代码来源:DroolsConfig.java
示例3: updateConditions
import org.kie.api.runtime.conf.ClockTypeOption; //导入依赖的package包/类
public void updateConditions(String expiration, Collection<FullTrigger> activeTriggers) {
expression = new Expression(expiration, activeTriggers);
log.debugf("Rules: \n %s", expression);
stop();
KieBaseConfiguration kieBaseConfiguration = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
kieBaseConfiguration.setOption( EventProcessingOption.STREAM );
KieBase kieBase = new KieHelper().addContent(expression.getDrl(), ResourceType.DRL).build(kieBaseConfiguration);
KieSessionConfiguration kieSessionConf = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
kieSessionConf.setOption( ClockTypeOption.get( "realtime" ) );
kieSession = kieBase.newKieSession(kieSessionConf, null);
results = new ArrayList<>();
kieSession.setGlobal("results", this);
kieSession.setGlobal("log", log);
if (log.isDebugEnabled()) {
kieSession.addEventListener(new CepAgendaEventListener());
kieSession.addEventListener(new CepRuleRuntimeEventListener());
}
log.debugf("Clock time [%s] ", kieSession.getSessionClock().getCurrentTime());
kieSession.getKieBase().getKiePackages().stream().forEach(p -> log.debugf("Rules: %s", p.getRules()));
executor.submit(() -> {
log.info("Starting fireUntilHalt()");
kieSession.fireUntilHalt();
log.info("Stopping fireUntilHalt()");
});
}
开发者ID:hawkular,项目名称:hawkular-alerts,代码行数:29,代码来源:CepEngineImpl.java
示例4: startSession
import org.kie.api.runtime.conf.ClockTypeOption; //导入依赖的package包/类
private void startSession(String drl) {
kieBaseConfiguration = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
kieBaseConfiguration.setOption( EventProcessingOption.STREAM );
kieBase = new KieHelper().addContent(drl, ResourceType.DRL).build(kieBaseConfiguration);
kieSessionConf = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
kieSessionConf.setOption( ClockTypeOption.get( "pseudo" ) );
kieSession = kieBase.newKieSession(kieSessionConf, null);
clock = kieSession.getSessionClock();
// kieSession.addEventListener(new DebugAgendaEventListener());
// kieSession.addEventListener(new DebugRuleRuntimeEventListener());
results = new ArrayList<>();
kieSession.setGlobal("clock", clock);
kieSession.setGlobal("results", new CepEngine() {
@Override
public void sendResult(Event event) {
results.add(event);
}
@Override
public void updateConditions(String expiration, Collection<FullTrigger> activeTriggers) { }
@Override
public void processEvents(TreeSet<Event> events) { }
@Override
public void stop() { }
});
}
开发者ID:hawkular,项目名称:hawkular-alerts,代码行数:29,代码来源:ExpressionTest.java
示例5: startSession
import org.kie.api.runtime.conf.ClockTypeOption; //导入依赖的package包/类
private void startSession(String drl) {
kieBaseConfiguration = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
kieBaseConfiguration.setOption( EventProcessingOption.STREAM );
kieBase = new KieHelper().addContent(drl, ResourceType.DRL).build(kieBaseConfiguration);
kieSessionConf = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
kieSessionConf.setOption( ClockTypeOption.get( "pseudo" ) );
kieSession = kieBase.newKieSession(kieSessionConf, null);
clock = kieSession.getSessionClock();
// kieSession.addEventListener(new DebugAgendaEventListener());
// kieSession.addEventListener(new DebugRuleRuntimeEventListener());
results = new ArrayList<>();
kieSession.setGlobal("clock", clock);
kieSession.setGlobal("results", results);
}
开发者ID:hawkular,项目名称:hawkular-alerts,代码行数:15,代码来源:DrlTests.java
示例6: init
import org.kie.api.runtime.conf.ClockTypeOption; //导入依赖的package包/类
@PostConstruct
public void init() {
KieServices kieServices = KieServices.Factory.get();
KieContainer kContainer = kieServices.getKieClasspathContainer();
KieBaseConfiguration kieBaseConf = kieServices.newKieBaseConfiguration();
kieBaseConf.setOption( EventProcessingOption.STREAM );
kieBase = kContainer.newKieBase(kieBaseConf);
for ( KiePackage kp : kieBase.getKiePackages() ) {
for (Rule rule : kp.getRules()) {
LOG.info("kp " + kp + " rule " + rule.getName());
}
}
LOG.info("Creating kieSession");
KieSessionConfiguration config = kieServices.newKieSessionConfiguration();
config.setOption( ClockTypeOption.get("pseudo") );
kieSession = kieBase.newKieSession(config, null);
LOG.info("Pupulating globals");
kieSession.setGlobal("LOG", RE_LOG);
sessionClock = kieSession.getSessionClock();
LOG.info("init() sessionClock: {}", sessionClock.getCurrentTime());
final long nowMS = System.currentTimeMillis();
sessionClock.advanceTime(nowMS, TimeUnit.MILLISECONDS);
LOG.info("init() sessionClock advanced, sessionClock: {}", sessionClock.getCurrentTime());
kieSession.fireAllRules(MAX_RULES_THRESHOLD);
LOG.info("init() onetime fireAllRules");
LOG.info("init() end.");
}
开发者ID:tarilabs,项目名称:reex2014,代码行数:35,代码来源:PseudoRealtimeRuleEngine.java
示例7: testCompareInstances
import org.kie.api.runtime.conf.ClockTypeOption; //导入依赖的package包/类
@Test
public void testCompareInstances() throws Exception {
KieBaseConfiguration config = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
config.setOption(EventProcessingOption.STREAM);
KnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase(config);
KieSessionConfiguration ksconf = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
ksconf.setOption(ClockTypeOption.get("pseudo"));
ksconf.setOption(TimerJobFactoryOption.get("trackable"));
StatefulKnowledgeSession ksessionA = knowledgeBase.newStatefulKnowledgeSession(ksconf, null);
StatefulKnowledgeSession ksessionB = knowledgeBase.newStatefulKnowledgeSession(ksconf, null);
Assert.assertTrue(KieGimcrack.class.getSimpleName() + " is broken!", kieGimcrack.compareInstances(ksessionA, ksessionB));
}
开发者ID:mrietveld,项目名称:gimcrack,代码行数:16,代码来源:TestMarshallingUtilsTest.java
示例8: initKieSession
import org.kie.api.runtime.conf.ClockTypeOption; //导入依赖的package包/类
private void initKieSession(String... resourceNames) {
final KieServices kieServices = KieServices.Factory.get();
final KieModuleModel kieModuleModel = kieServices.newKieModuleModel();
final KieBaseModel kieBaseModel = kieModuleModel.newKieBaseModel("defaultKieBase")
.setDefault(true)
.setEqualsBehavior(EqualityBehaviorOption.EQUALITY)
.setEventProcessingMode(EventProcessingOption.STREAM);
kieBaseModel.newKieSessionModel("defaultKieSession")
.setDefault(true)
.setType(KieSessionModel.KieSessionType.STATEFUL)
.setClockType(ClockTypeOption.get("pseudo"))
.newWorkItemHandlerModel("Rest", "org.drools.workbench.screens.testscenario.backend.server.GithubContributorsWIH");
final KieFileSystem kfs = kieServices.newKieFileSystem();
kfs.writeKModuleXML(kieModuleModel.toXML());
for (String resource : resourceNames) {
kfs.write(ResourceFactory.newUrlResource(this.getClass()
.getResource(resource)
.toString()));
}
kieServices.newKieBuilder(kfs).buildAll();
kieContainer = kieServices.newKieContainer(kieServices.getRepository().getDefaultReleaseId());
kieSession = kieContainer.newKieSession();
doReturn(kieSession).when(sessionService).newDefaultKieSessionWithPseudoClock(any(KieModule.class));
}
开发者ID:kiegroup,项目名称:drools-wb,代码行数:29,代码来源:ScenarioRunnerServiceTest.java
示例9: buildKieSession
import org.kie.api.runtime.conf.ClockTypeOption; //导入依赖的package包/类
public static KieSession buildKieSession(KieBase kieBase) {
KieSessionConfiguration sessionConf = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
sessionConf.setOption(ClockTypeOption.get(ClockType.PSEUDO_CLOCK.getId()));
KieSession session = kieBase.newKieSession(sessionConf, null);
return session;
}
开发者ID:redhat-italy,项目名称:hacep,代码行数:7,代码来源:KieAPITestUtils.java
注:本文中的org.kie.api.runtime.conf.ClockTypeOption类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论