if (!ConfigUtils.isEmptyCollection(scoreDrlList) && !ConfigUtils.isEmptyCollection(scoreDrlFileList)) {
throw new IllegalArgumentException("The scoreDrlList (" + scoreDrlList
+ ") and the scoreDrlFileList (" + scoreDrlFileList + ") cannot both be non empty.");
}
KieServices kieServices = KieServices.Factory.get();
KieResources kieResources = kieServices.getResources();
KieFileSystem kieFileSystem = kieServices.newKieFileSystem();
if (!ConfigUtils.isEmptyCollection(scoreDrlList)) {
for (String scoreDrl : scoreDrlList) {
if (scoreDrl == null) {
throw new IllegalArgumentException("The scoreDrl (" + scoreDrl + ") cannot be null.");
}
URL scoreDrlURL = getClass().getClassLoader().getResource(scoreDrl);
if (scoreDrlURL == null) {
String errorMessage = "The scoreDrl (" + scoreDrl + ") does not exist as a classpath resource.";
if (scoreDrl.startsWith("/")) {
errorMessage += "\nAs from 6.1, a classpath resource should not start with a slash (/)."
+ " A scoreDrl now adheres to ClassLoader.getResource(String)."
+ " Remove the leading slash from the scoreDrl if you're upgrading from 6.0.";
}
throw new IllegalArgumentException(errorMessage);
}
kieFileSystem.write(kieResources.newClassPathResource(scoreDrl, "UTF-8"));
}
}
if (!ConfigUtils.isEmptyCollection(scoreDrlFileList)) {
for (File scoreDrlFile : scoreDrlFileList) {
if (scoreDrlFile == null) {
throw new IllegalArgumentException("The scoreDrlFile (" + scoreDrlFile + ") cannot be null.");
}
if (!scoreDrlFile.exists()) {
throw new IllegalArgumentException("The scoreDrlFile (" + scoreDrlFile
+ ") does not exist.");
}
kieFileSystem.write(kieResources.newFileSystemResource(scoreDrlFile, "UTF-8"));
}
}
KieBuilder kieBuilder = kieServices.newKieBuilder(kieFileSystem);
kieBuilder.buildAll();
Results results = kieBuilder.getResults();