use of org.drools.compiler.kie.builder.impl.KieBaseUpdaters in project drools by kiegroup.
the class CanonicalKieModule method afterKieBaseCreationUpdate.
@Override
public void afterKieBaseCreationUpdate(String name, InternalKnowledgeBase kBase) {
KnowledgeBuilder knowledgeBuilderForKieBase = getKnowledgeBuilderForKieBase(name);
final List<KieBaseUpdaterOptions.OptionEntry> options;
if (knowledgeBuilderForKieBase instanceof KnowledgeBuilderImpl) {
// When using executable module in tests
KnowledgeBuilderImpl knowledgeBuilderForImpl = (KnowledgeBuilderImpl) knowledgeBuilderForKieBase;
KnowledgeBuilderConfigurationImpl builderConfiguration = knowledgeBuilderForImpl.getBuilderConfiguration();
options = singletonList(new KieBaseUpdaterOptions.OptionEntry(AlphaNetworkCompilerOption.class, builderConfiguration.getAlphaNetworkCompilerOption()));
} else if (resourceFileExists(getANCFile(internalKieModule.getReleaseId()))) {
// executable model with ANC
options = singletonList(new KieBaseUpdaterOptions.OptionEntry(AlphaNetworkCompilerOption.class, AlphaNetworkCompilerOption.LOAD));
} else {
// Default case when loaded from executable model kjar
options = emptyList();
}
KieContainerImpl.CompositeRunnable compositeUpdater = new KieContainerImpl.CompositeRunnable();
KieBaseUpdaters updaters = KieService.load(KieBaseUpdaters.class);
updaters.getChildren().stream().map(kbu -> kbu.create(new KieBaseUpdatersContext(new KieBaseUpdaterOptions(options), kBase.getRete(), kBase.getRootClassLoader()))).forEach(compositeUpdater::add);
compositeUpdater.run();
}
Aggregations