}
return kBase;
}
private KieBase createKieBase(String kBaseName, KieProject kieProject, ResultsImpl messages, KieBaseConfiguration conf) {
KieBaseModelImpl kBaseModel = (KieBaseModelImpl) kProject.getKieBaseModel(kBaseName);
if (kBaseModel == null) {
throw new RuntimeException( "The requested KieBase \"" + kBaseName + "\" does not exist" );
}
ClassLoader cl = kieProject.getClassLoader();
InternalKieModule kModule = kieProject.getKieModuleForKBase( kBaseModel.getName() );
Collection<KnowledgePackage> pkgs = kModule.getKnowledgePackagesForKieBase(kBaseModel.getName());
if ( pkgs == null ) {
KnowledgeBuilder kbuilder = buildKnowledgePackages(kBaseModel, kieProject, messages);
if ( kbuilder.hasErrors() ) {
// Messages already populated by the buildKnowlegePackages
return null;
}
}
// if we get to here, then we know the pkgs is now cached
pkgs = kModule.getKnowledgePackagesForKieBase(kBaseModel.getName());
if ( kBaseModel.getEventProcessingMode() == EventProcessingOption.CLOUD &&
(conf == null || conf.getOption(EventProcessingOption.class) == EventProcessingOption.CLOUD ) ) {
for (KnowledgePackage kpkg : pkgs) {
if ( ((KnowledgePackageImp) kpkg).pkg.needsStreamMode() ) {
throw new RuntimeException( "The requested KieBase \"" + kBaseName + "\" has been set to run in CLOUD mode but requires features only available in STREAM mode" );
}