org.kie.kogito.examples.PersonValidationServiceRuleUnit Maven / Gradle / Ivy
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;
@org.springframework.stereotype.Component()
public class PersonValidationServiceRuleUnit extends AbstractRuleUnit {
@org.springframework.beans.factory.annotation.Autowired()
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.KogitoStatefulKnowledgeSessionImpl) 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 - 2025 Weber Informatics LLC | Privacy Policy