}
return kBase;
}
private KieBase createKieBase(String kBaseName, KieProject kieProject, ResultsImpl messages) {
KieBaseModelImpl kBaseModel = (KieBaseModelImpl) kProject.getKieBaseModel(kBaseName);
CompositeClassLoader cl = kieProject.getClassLoader(); // the most clone the CL, as each builder and rbase populates it
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());
InternalKnowledgeBase kBase = (InternalKnowledgeBase) KnowledgeBaseFactory.newKnowledgeBase( getKnowledgeBaseConfiguration(kBaseModel, cl) );
kBase.addKnowledgePackages( pkgs );
return kBase;