}
}
}
public PackageRegistry newPackage(final PackageDescr packageDescr) {
InternalKnowledgePackage pkg;
if (this.kBase == null || (pkg = this.kBase.getPackage(packageDescr.getName())) == null) {
// there is no rulebase or it does not define this package so define it
pkg = new KnowledgePackageImpl(packageDescr.getName());
pkg.setClassFieldAccessorCache(new ClassFieldAccessorCache(this.rootClassLoader));
// if there is a rulebase then add the package.
if (this.kBase != null) {
// Must lock here, otherwise the assumption about addPackage/getPackage behavior below might be violated
this.kBase.lock();
try {
this.kBase.addPackage(pkg);
pkg = this.kBase.getPackage(packageDescr.getName());
} finally {
this.kBase.unlock();
}
} else {
// the RuleBase will also initialise the
pkg.getDialectRuntimeRegistry().onAdd(this.rootClassLoader);
}
}
PackageRegistry pkgRegistry = new PackageRegistry(rootClassLoader, configuration, pkg);