use of org.drools.core.ActivationListenerFactory in project drools by kiegroup.
the class NamedConsequenceBuilder method buildTerminalNodeForNamedConsequence.
static RuleTerminalNode buildTerminalNodeForNamedConsequence(BuildContext context, NamedConsequence namedConsequence) {
RuleImpl rule = context.getRule();
GroupElement subrule = (GroupElement) context.peek();
ActivationListenerFactory factory = context.getKnowledgeBase().getConfiguration().getActivationListenerFactory(rule.getActivationListener());
context.setConsequenceName(namedConsequence.getConsequenceName());
TerminalNode terminal = factory.createActivationListener(context.getNextId(), context.getTupleSource(), rule, subrule, // subruleIndex,
0, context);
context.setConsequenceName(null);
return (RuleTerminalNode) terminal;
}
use of org.drools.core.ActivationListenerFactory in project drools by kiegroup.
the class ReteooRuleBuilder method addSubRule.
private TerminalNode addSubRule(final BuildContext context, final GroupElement subrule, final int subruleIndex, final RuleImpl rule) throws InvalidPatternException {
context.setSubRule(subrule);
// gets the appropriate builder
ReteooComponentBuilder builder = this.utils.getBuilderFor(subrule);
// checks if an initial-fact is needed
if (builder.requiresLeftActivation(this.utils, subrule)) {
this.addInitialFactPattern(subrule);
}
// builds and attach
builder.build(context, this.utils, subrule);
if (context.isTerminated()) {
context.setTerminated(false);
return ((TerminalNode) context.getLastNode());
}
if (rule.getTimer() != null) {
builder = this.utils.getBuilderFor(Timer.class);
builder.build(context, this.utils, rule.getTimer());
}
ActivationListenerFactory factory = context.getKnowledgeBase().getConfiguration().getActivationListenerFactory(rule.getActivationListener());
TerminalNode terminal = factory.createActivationListener(context.getNextId(), context.getTupleSource(), rule, subrule, subruleIndex, context);
BaseNode baseTerminalNode = (BaseNode) terminal;
baseTerminalNode.networkUpdated(new UpdateContext());
baseTerminalNode.attach(context);
setPathEndNodes(context);
AddRemoveRule.addRule(terminal, context.getWorkingMemories(), context.getKnowledgeBase());
// adds the terminal node to the list of nodes created/added by this sub-rule
context.getNodes().add(baseTerminalNode);
return terminal;
}
Aggregations