use of org.drools.compiler.kie.builder.impl.KieModuleCache.CompDataEntry in project drools by kiegroup.
the class AbstractKieModule method getCompilationCache.
@Override
public CompilationCache getCompilationCache(String kbaseName) {
// Map< DIALECT, Map< RESOURCE, List<BYTECODE> > >
CompilationCache cache = compilationCache.get(kbaseName);
if (cache == null) {
byte[] fileContents = getBytes(KieBuilderImpl.getCompilationCachePath(releaseId, kbaseName));
if (fileContents != null) {
ExtensionRegistry registry = KieModuleCacheHelper.buildRegistry();
try {
Header _header = KieModuleCacheHelper.readFromStreamWithHeaderPreloaded(new ByteArrayInputStream(fileContents), registry);
if (!Drools.isCompatible(_header.getVersion().getVersionMajor(), _header.getVersion().getVersionMinor(), _header.getVersion().getVersionRevision())) {
// if cache has been built with an incompatible version avoid to use it
log.warn("The compilation cache has been built with an incompatible version. " + "You should recompile your project in order to use it with current release.");
return null;
}
KModuleCache _cache = KModuleCache.parseFrom(_header.getPayload());
cache = new CompilationCache();
for (CompilationData _data : _cache.getCompilationDataList()) {
for (CompDataEntry _entry : _data.getEntryList()) {
cache.addEntry(_data.getDialect(), _entry.getId(), _entry.getData().toByteArray());
}
}
compilationCache.put(kbaseName, cache);
} catch (Exception e) {
log.error("Unable to load compilation cache... ", e);
}
}
}
return cache;
}
Aggregations