当前位置: 首页>>代码示例>>Java>>正文


Java StatefulKnowledgeSession.addEventListener方法代码示例

本文整理汇总了Java中org.drools.runtime.StatefulKnowledgeSession.addEventListener方法的典型用法代码示例。如果您正苦于以下问题:Java StatefulKnowledgeSession.addEventListener方法的具体用法?Java StatefulKnowledgeSession.addEventListener怎么用?Java StatefulKnowledgeSession.addEventListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.drools.runtime.StatefulKnowledgeSession的用法示例。


在下文中一共展示了StatefulKnowledgeSession.addEventListener方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: assertAndExecuteClinicalFacts

import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
@Override
public AssertAndExecuteClinicalFactsResponse assertAndExecuteClinicalFacts(
        FactModel factModel) {
    RuleExecutionContainer executionResponseContainer = null;
    final AssertAndExecuteClinicalFactsResponse assertAndExecuteResponse = new AssertAndExecuteClinicalFactsResponse();
    String executionResponseContainerXMLString = null;
    final Set<String> firedRuleNames = new HashSet<>();

    final StatefulKnowledgeSession session = createStatefulKnowledgeSession();
    try {
        session.insert(factModel.getXacmlResult());
        for (final ClinicalFact clinicalFact : factModel
                .getClinicalFactList()) {
            session.insert(clinicalFact);
        }

        session.addEventListener(new DefaultAgendaEventListener() {
            @Override
            public void afterActivationFired(AfterActivationFiredEvent event) {
                super.afterActivationFired(event);
                final Rule rule = event.getActivation().getRule();
                firedRuleNames.add(rule.getName());
            }
        });

        session.fireAllRules();

        logger.debug(() -> "Fired rules: " + firedRuleNames.toString());

        executionResponseContainer = (RuleExecutionContainer) session
                .getGlobal("ruleExecutionContainer");

        // Marshal rule execution response
        executionResponseContainerXMLString = marshaller
                .marshal(executionResponseContainer);
        if (firedRuleNames.size() > 0) {
            assertAndExecuteResponse.setRulesFired(firedRuleNames
                    .toString());
        }
    } catch (final Throwable e) {
        logger.error(e.getMessage(), e);
    } finally {
        firedRuleNames.clear();
        if (session != null) {
            session.dispose();
        }
    }
    assertAndExecuteResponse
            .setRuleExecutionResponseContainer(executionResponseContainerXMLString);
    return assertAndExecuteResponse;
}
 
开发者ID:bhits,项目名称:dss-api,代码行数:52,代码来源:RuleExecutionServiceImpl.java

示例2: assertAndExecuteClinicalFacts

import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
@Override
public AssertAndExecuteClinicalFactsResponse assertAndExecuteClinicalFacts(
		String factModelXmlString) {
	RuleExecutionContainer executionResponseContainer = null;
	FactModel factModel = new FactModel();
	AssertAndExecuteClinicalFactsResponse assertAndExecuteResponse = new AssertAndExecuteClinicalFactsResponse();

	String executionResponseContainerXMLString = null;

	LOGGER.debug("factModelXmlString: " + factModelXmlString);
	StatefulKnowledgeSession session = createStatefulKnowledgeSession();
	try {
		// unmarshall factmodel
		factModel = marshaller.unmarshallFromXml(FactModel.class,
				factModelXmlString);

		session.insert(factModel.getXacmlResult());
		for (ClinicalFact clinicalFact : factModel.getClinicalFactList()) {
			session.insert(clinicalFact);
		}

		session.addEventListener(new DefaultAgendaEventListener() {
			@Override
			public void afterActivationFired(AfterActivationFiredEvent event) {
				super.afterActivationFired(event);
				final Rule rule = event.getActivation().getRule();
				addRuleName(rule.getName());

			}
		});

		session.fireAllRules();

		LOGGER.debug("Fired rules: {}...", firedRuleNames);
		LOGGER.debug("Fired rules: " + firedRuleNames);

		executionResponseContainer = (RuleExecutionContainer) session
				.getGlobal("ruleExecutionContainer");

		// Marshal rule execution response
		executionResponseContainerXMLString = marshaller
				.marshall(executionResponseContainer);

	} catch (Throwable e) {
		LOGGER.error(e.getMessage(), e);
	} finally {
		firedRuleNames = "";
		if (session != null) {
			session.dispose();
		}
	}

	assertAndExecuteResponse
			.setRuleExecutionResponseContainer(executionResponseContainerXMLString);

	return assertAndExecuteResponse;
}
 
开发者ID:tlin-fei,项目名称:ds4p,代码行数:58,代码来源:RuleExecutionServiceImpl.java

示例3: JbpmWorkflowEngine

import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
public JbpmWorkflowEngine(StatefulKnowledgeSession session, ProcessListenerManager processListenerManager) {
	this.session = session;
	session.addEventListener(processListenerManager);
}
 
开发者ID:frincon,项目名称:openeos,代码行数:5,代码来源:JbpmWorkflowEngine.java


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