• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java KieSessionConfiguration类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.kie.api.runtime.KieSessionConfiguration的典型用法代码示例。如果您正苦于以下问题:Java KieSessionConfiguration类的具体用法?Java KieSessionConfiguration怎么用?Java KieSessionConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



KieSessionConfiguration类属于org.kie.api.runtime包,在下文中一共展示了KieSessionConfiguration类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: loadDrools

import org.kie.api.runtime.KieSessionConfiguration; //导入依赖的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: writeObject

import org.kie.api.runtime.KieSessionConfiguration; //导入依赖的package包/类
public static byte[] writeObject(Marshaller marshaller, KieSession kieSession) {
    try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
         ObjectOutputStream oos = new ObjectOutputStream(outputStream);) {
        /*
         * It seems that the Marshaller does not persist the actual SessionClock, which is a problem when using the PseudoClock, so we
         * persist the SessionConfiguration, Environment and clock time to be able to execute the pseudo-clock (if it's used).
         */
        KieSessionConfiguration kieSessionConfiguration = kieSession.getSessionConfiguration();
        oos.writeObject(kieSessionConfiguration);

        marshaller.marshall(outputStream, kieSession);

        byte[] bytes = outputStream.toByteArray();

        if (LOGGER.isInfoEnabled()) {
            LOGGER.info("Size of session is: " + bytes.length);
        }
        return bytes;
    } catch (IOException ioe) {
        String errorMessage = "Unable to marshall KieSession.";
        LOGGER.error(errorMessage, ioe);
        throw new RuntimeException(errorMessage, ioe);
    }
}
 
开发者ID:redhat-italy,项目名称:hacep,代码行数:25,代码来源:KieSessionByteArraySerializer.java


示例3: start

import org.kie.api.runtime.KieSessionConfiguration; //导入依赖的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


示例4: readSession

import org.kie.api.runtime.KieSessionConfiguration; //导入依赖的package包/类
public static KieSession readSession(Marshaller marshaller, byte[] serializedKieSession) {
    try (ByteArrayInputStream inputStream = new ByteArrayInputStream(serializedKieSession);
         ObjectInputStream ois = new ObjectInputStream(inputStream);) {
        KieSessionConfiguration kieSessionConfiguration = (KieSessionConfiguration) ois.readObject();
        return marshaller.unmarshall(inputStream, kieSessionConfiguration, null);
    } catch (Exception e) {
        LOGGER.error("Error when reading serialized session", e);
        throw new RuntimeException(e);
    }
}
 
开发者ID:redhat-italy,项目名称:hacep,代码行数:11,代码来源:KieSessionByteArraySerializer.java


示例5: updateConditions

import org.kie.api.runtime.KieSessionConfiguration; //导入依赖的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


示例6: init

import org.kie.api.runtime.KieSessionConfiguration; //导入依赖的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.KieSessionConfiguration; //导入依赖的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: buildKieSession

import org.kie.api.runtime.KieSessionConfiguration; //导入依赖的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


示例9: newKieSessionConfiguration

import org.kie.api.runtime.KieSessionConfiguration; //导入依赖的package包/类
@Override
public KieSessionConfiguration newKieSessionConfiguration() {
	return kieServices.newKieSessionConfiguration();
}
 
开发者ID:deepu105,项目名称:drools-demo,代码行数:5,代码来源:DefaultKieServicesBean.java


示例10: newKieSession

import org.kie.api.runtime.KieSessionConfiguration; //导入依赖的package包/类
@Override
public KieSession newKieSession(KieSessionConfiguration conf) {
    return kieContainer.newKieSession(conf);
}
 
开发者ID:deepu105,项目名称:drools-demo,代码行数:5,代码来源:DefaultKieContainerBean.java


示例11: newStatelessKieSession

import org.kie.api.runtime.KieSessionConfiguration; //导入依赖的package包/类
@Override
public StatelessKieSession newStatelessKieSession(
        KieSessionConfiguration conf) {
    return kieContainer.newStatelessKieSession(conf);
}
 
开发者ID:deepu105,项目名称:drools-demo,代码行数:6,代码来源:DefaultKieContainerBean.java


示例12: getSessionConfiguration

import org.kie.api.runtime.KieSessionConfiguration; //导入依赖的package包/类
public KieSessionConfiguration getSessionConfiguration() {
    return kieSession.getSessionConfiguration();
}
 
开发者ID:deepu105,项目名称:drools-demo,代码行数:4,代码来源:DefaultKieSessionBean.java


示例13: createKnowledgeSessionFromKBase

import org.kie.api.runtime.KieSessionConfiguration; //导入依赖的package包/类
public static StatefulKnowledgeSession createKnowledgeSessionFromKBase(KnowledgeBase kbase, HashMap<String, Object> context) {
    KieSessionConfiguration ksconf = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
    StatefulKnowledgeSession knowledgeSession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, ksconf, createEnvironment(context));
    return knowledgeSession;
}
 
开发者ID:mrietveld,项目名称:gimcrack,代码行数:6,代码来源:PersistenceUtil.java



注:本文中的org.kie.api.runtime.KieSessionConfiguration类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Translet类代码示例发布时间:2022-05-23
下一篇:
Java AspectJTypeFilter类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap