All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.kie.kogito.examples.PersonValidationServiceRuleUnit Maven / Gradle / Ivy

There is a newer version: 0.9.0
Show newest version
package org.kie.kogito.examples;

import org.kie.api.runtime.KieSession;
import org.kie.kogito.rules.RuleEventListenerConfig;
import org.kie.kogito.rules.units.impl.AbstractRuleUnit;

@javax.inject.Singleton()
public class PersonValidationServiceRuleUnit extends AbstractRuleUnit {

    public PersonValidationServiceRuleUnit() {
        this(new org.kie.kogito.examples.Application());
    }

    @javax.inject.Inject()
    public PersonValidationServiceRuleUnit(org.kie.kogito.Application app) {
        super(app);
    }

    public org.kie.kogito.examples.PersonValidationServiceRuleUnitInstance internalCreateInstance(PersonValidationService value) {
        return new org.kie.kogito.examples.PersonValidationServiceRuleUnitInstance(this, value, createLegacySession());
    }

    private KieSession createLegacySession() {
        KieSession ks = app.ruleUnits().ruleRuntimeBuilder().newKieSession(PersonValidationService.class);
        ((org.drools.core.impl.StatefulKnowledgeSessionImpl) ks).setApplication(app);
        if (app.config() != null && app.config().rule() != null) {
            RuleEventListenerConfig ruleEventListenerConfig = app.config().rule().ruleEventListeners();
            ruleEventListenerConfig.agendaListeners().forEach(ks::addEventListener);
            ruleEventListenerConfig.ruleRuntimeListeners().forEach(ks::addEventListener);
        }
        return ks;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy