本文整理汇总了Java中org.kie.api.KieBaseConfiguration类的典型用法代码示例。如果您正苦于以下问题:Java KieBaseConfiguration类的具体用法?Java KieBaseConfiguration怎么用?Java KieBaseConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
KieBaseConfiguration类属于org.kie.api包,在下文中一共展示了KieBaseConfiguration类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initKie
import org.kie.api.KieBaseConfiguration; //导入依赖的package包/类
private void initKie() {
KieServices ks = KieServices.Factory.get();
kfs = ks.newKieFileSystem();
uploadDroolFiles();
KieBuilder kbuilder = ks.newKieBuilder(kfs);
kbuilder.buildAll();
if (kbuilder.getResults().hasMessages(Level.ERROR)) {
throw new IllegalArgumentException(kbuilder.getResults().toString());
}
KieContainer kcontainer = ks.newKieContainer(kbuilder.getKieModule().getReleaseId());
KieBaseConfiguration kbConfig = KieServices.Factory.get().newKieBaseConfiguration();
kbConfig.setOption(ConstraintJittingThresholdOption.get(-1));
kbase = kcontainer.newKieBase(kbConfig);
}
示例2: setupKieBase
import org.kie.api.KieBaseConfiguration; //导入依赖的package包/类
public static KieBase setupKieBase(String... resources) throws Exception {
ReleaseId releaseId = ks.newReleaseId("it.redhat.jdg", "rules", "1.0.0");
KieContainer kieContainer = setupKieContainerFromTemplates(releaseId, resources);
KieBaseConfiguration config = KieServices.Factory.get().newKieBaseConfiguration();
config.setOption(EventProcessingOption.STREAM);
return kieContainer.getKieBase();
}
示例3: updateConditions
import org.kie.api.KieBaseConfiguration; //导入依赖的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()");
});
}
示例4: init
import org.kie.api.KieBaseConfiguration; //导入依赖的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.");
}
示例5: sharedSetup
import org.kie.api.KieBaseConfiguration; //导入依赖的package包/类
private void sharedSetup()
{
logger.debug("Configuring KnowledgeBase Configuration for " + name_);
KieBaseConfiguration kBaseConfig = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
Class<? extends ConsequenceExceptionHandler> c = DroolsExceptionHandler.class;
ConsequenceExceptionHandlerOption cehOption = ConsequenceExceptionHandlerOption.get(c);
kBaseConfig.setOption(cehOption);
if (drools_dialect_java_compiler != null)
{
kBaseConfig.setProperty("drools.dialect.java.compiler", drools_dialect_java_compiler);
}
kbase_ = KnowledgeBaseFactory.newKnowledgeBase(kBaseConfig);
}
示例6: testCompareInstances
import org.kie.api.KieBaseConfiguration; //导入依赖的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));
}
示例7: newKieBaseConfiguration
import org.kie.api.KieBaseConfiguration; //导入依赖的package包/类
@Override
public KieBaseConfiguration newKieBaseConfiguration() {
return kieServices.newKieBaseConfiguration();
}
示例8: newKieBase
import org.kie.api.KieBaseConfiguration; //导入依赖的package包/类
@Override
public KieBase newKieBase(KieBaseConfiguration conf) {
return kieContainer.newKieBase(conf);
}