PackageBuilder builder = new PackageBuilder(cfg);
builder.addPackageFromDrl(drl, new StringReader(getDslFiles()));
PackageBuilderErrors errors = builder.getErrors();
if (errors.getErrors().length == 0) {
Package pkg = builder.getPackage();
ObjectOutputStream oos = null;
try {
oos = new ObjectOutputStream(new FileOutputStream(pkgFile));
oos.writeObject(pkg);
} catch (IOException e) {
logger.error("Error writing rule package to a file.", e);
} finally {
IOUtils.closeQuietly(oos);
}
if (ruleBase.getPackage(pkg.getName()) != null) {
ruleBase.removePackage(pkg.getName());
}
ruleBase.addPackage(pkg);
logger.info("Rules for " + pkg.getName() + " updated in " + (System.currentTimeMillis() - start) + "ms.");
} else {
logger.error("---------------------------------------------------------------------------------");
logger.error("Errors when compiling rules in " + dsrlFile + " : " + errors.toString());
logger.error("---------------------------------------------------------------------------------");
}
}
} catch (ClassNotFoundException e) {
logger.error(e.getMessage(), e);