org.kie.api.event.rule.BeforeMatchFiredEvent Java Examples

The following examples show how to use org.kie.api.event.rule.BeforeMatchFiredEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WorkingMemoryLogger.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
/**
 * @see org.kie.api.event.rule.AgendaEventListener
 */
public void beforeMatchFired(BeforeMatchFiredEvent event) {
    filterLogEvent( new ActivationLogEvent( LogEvent.BEFORE_ACTIVATION_FIRE,
                                            getActivationId( event.getMatch() ),
                                            event.getMatch().getRule().getName(),
                                            extractDeclarations( event.getMatch() ),
                                            ((RuleImpl)event.getMatch().getRule()).getRuleFlowGroup(),
                                            extractFactHandleIds( (Activation) event.getMatch() ) ) );
}
 
Example #2
Source File: AgendaEventSupport.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
public void fireAfterActivationFired(final Activation activation,
                                     final InternalWorkingMemory workingMemory, 
                                     BeforeMatchFiredEvent beforeMatchFiredEvent) {
    Iterator<AgendaEventListener> iter = getEventListenersIterator();
    AfterMatchFiredEvent event = new AfterActivationFiredEventImpl(activation, getKRuntime(workingMemory), beforeMatchFiredEvent);

    if (iter.hasNext()) {
        
        do{
            iter.next().afterMatchFired(event);
        }  while (iter.hasNext());
    }
}
 
Example #3
Source File: AgendaEventSupport.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
public BeforeMatchFiredEvent fireBeforeActivationFired(final Activation activation,
                                      final WorkingMemory workingMemory) {
    Iterator<AgendaEventListener> iter = getEventListenersIterator();
    BeforeMatchFiredEvent event = new BeforeActivationFiredEventImpl(activation, getKRuntime(workingMemory));

    if (iter.hasNext()) {
        
        do{
            iter.next().beforeMatchFired(event);
        }  while (iter.hasNext());
    }
    
    return event;
}
 
Example #4
Source File: DebugAgendaEventListener.java    From servicemix with Apache License 2.0 4 votes vote down vote up
/**
 * @see AgendaEventListener#beforeMatchFired(org.kie.api.event.rule.BeforeMatchFiredEvent)
 */
@Override
public void beforeMatchFired(BeforeMatchFiredEvent event) {
    log.info("{}", event);

}
 
Example #5
Source File: RuleCoverageListener.java    From kogito-runtimes with Apache License 2.0 4 votes vote down vote up
public void beforeMatchFired(BeforeMatchFiredEvent event) {
}
 
Example #6
Source File: DebugAgendaEventListener.java    From servicemix with Apache License 2.0 4 votes vote down vote up
/**
 * @see AgendaEventListener#beforeMatchFired(org.kie.api.event.rule.BeforeMatchFiredEvent)
 */
@Override
public void beforeMatchFired(BeforeMatchFiredEvent event) {
    log.info("{}", event);

}
 
Example #7
Source File: DebugAgendaEventListener.java    From servicemix with Apache License 2.0 4 votes vote down vote up
/**
 * @see AgendaEventListener#beforeMatchFired(org.kie.api.event.rule.BeforeMatchFiredEvent)
 */
@Override
public void beforeMatchFired(BeforeMatchFiredEvent event) {
    log.info("{}", event);

}
 
Example #8
Source File: CepEngineImpl.java    From hawkular-alerts with Apache License 2.0 4 votes vote down vote up
@Override
public void beforeMatchFired(BeforeMatchFiredEvent event) {
    log.debug(event);
}
 
Example #9
Source File: PrometheusMetricsDroolsListener.java    From kogito-runtimes with Apache License 2.0 4 votes vote down vote up
public BeforeActivationFiredEventImpl getBeforeImpl(BeforeMatchFiredEvent e) {
    return (BeforeActivationFiredEventImpl)e;
}
 
Example #10
Source File: PrometheusMetricsDroolsListener.java    From kogito-runtimes with Apache License 2.0 4 votes vote down vote up
@Override
public void beforeMatchFired(BeforeMatchFiredEvent event) {
    long nanoTime = System.nanoTime();
    BeforeActivationFiredEventImpl impl = getBeforeImpl(event);
    impl.setTimestamp(nanoTime);
}
 
Example #11
Source File: AfterActivationFiredEventImpl.java    From kogito-runtimes with Apache License 2.0 4 votes vote down vote up
public BeforeMatchFiredEvent getBeforeMatchFiredEvent() {
    return beforeMatchFiredEvent;
}
 
Example #12
Source File: AfterActivationFiredEventImpl.java    From kogito-runtimes with Apache License 2.0 4 votes vote down vote up
public AfterActivationFiredEventImpl(Match activation, KieRuntime kruntime, BeforeMatchFiredEvent beforeMatchFiredEvent) {
    super( activation, kruntime );
    this.beforeMatchFiredEvent = beforeMatchFiredEvent;
}
 
Example #13
Source File: DebugAgendaEventListener.java    From kogito-runtimes with Apache License 2.0 4 votes vote down vote up
public void beforeMatchFired(BeforeMatchFiredEvent event) {
    logger.info( event.toString() );
}
 
Example #14
Source File: DefaultAgendaEventListener.java    From kogito-runtimes with Apache License 2.0 4 votes vote down vote up
public void beforeMatchFired(BeforeMatchFiredEvent event) {
    // intentionally left blank
}
 
Example #15
Source File: RuleExecutor.java    From kogito-runtimes with Apache License 2.0 4 votes vote down vote up
public void fireActivation(InternalWorkingMemory wm, InternalAgenda agenda, Activation activation) throws ConsequenceException {
    // We do this first as if a node modifies a fact that causes a recursion
    // on an empty pattern
    // we need to make sure it re-activates
    wm.startOperation();
    try {
        BeforeMatchFiredEvent beforeMatchFiredEvent = wm.getAgendaEventSupport().fireBeforeActivationFired(activation, wm);

        if ( activation.getActivationGroupNode() != null ) {
            // We know that this rule will cancel all other activations in the group
            // so lets remove the information now, before the consequence fires
            final InternalActivationGroup activationGroup = activation.getActivationGroupNode().getActivationGroup();
            activationGroup.removeActivation( activation );
            agenda.clearAndCancelActivationGroup( activationGroup);
        }
        activation.setQueued(false);

        try {
            innerFireActivation( wm, agenda, activation, activation.getConsequence() );
        } finally {
            // if the tuple contains expired events
            for ( Tuple tuple = activation.getTuple(); tuple != null; tuple = tuple.getParent() ) {
                if ( tuple.getFactHandle() != null && tuple.getFactHandle().isEvent() ) {
                    // can be null for eval, not and exists that have no right input

                    EventFactHandle handle = ( EventFactHandle ) tuple.getFactHandle();
                    // decrease the activation count for the event
                    handle.decreaseActivationsCount();
                    // handles "expire" only in stream mode.
                    if ( handle.expirePartition() && handle.isExpired() &&
                            handle.getFirstRightTuple() == null && handle.getActivationsCount() <= 0 ) {
                        // and if no more activations, retract the handle
                        handle.getEntryPoint().delete( handle );
                    }
                }
            }
        }

        wm.getAgendaEventSupport().fireAfterActivationFired( activation, wm, beforeMatchFiredEvent );
    } finally {
        wm.endOperation();
    }
}
 
Example #16
Source File: GenericKieSessionMonitoringImpl.java    From kogito-runtimes with Apache License 2.0 4 votes vote down vote up
public void beforeMatchFired(BeforeMatchFiredEvent event) {
    AgendaStatsData data = getRuleStatsInstance( event.getMatch().getRule().getName() );
    this.consolidated.startFireClock();
    data.startFireClock();
}
 
Example #17
Source File: TestingEventListener.java    From kogito-runtimes with Apache License 2.0 4 votes vote down vote up
public void beforeMatchFired(BeforeMatchFiredEvent event) {
}
 
Example #18
Source File: TriggerRulesEventListener.java    From kogito-runtimes with Apache License 2.0 2 votes vote down vote up
@Override
public void beforeMatchFired(BeforeMatchFiredEvent event) {
    
}