本文整理汇总了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;
}
示例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;
}
示例3: JbpmWorkflowEngine
import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
public JbpmWorkflowEngine(StatefulKnowledgeSession session, ProcessListenerManager processListenerManager) {
this.session = session;
session.addEventListener(processListenerManager);
}