org.kie.kogito.examples.PersonValidationServiceRuleUnit Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jbpm-quarkus-example
Show all versions of jbpm-quarkus-example
Order management service
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;
}
}