use of org.hibernate.jpamodelgen.util.FileTimeStampChecker in project hibernate-orm by hibernate.
the class JpaDescriptorParser method mappingFilesUnchanged.
private boolean mappingFilesUnchanged(Collection<String> mappingFileNames) {
boolean mappingFilesUnchanged = false;
FileTimeStampChecker fileStampCheck = new FileTimeStampChecker();
for (String mappingFile : mappingFileNames) {
try {
URL url = this.getClass().getResource(mappingFile);
if (url == null) {
continue;
}
File file = new File(url.toURI());
context.logMessage(Diagnostic.Kind.OTHER, "Check file " + mappingFile);
if (file.exists()) {
fileStampCheck.add(mappingFile, file.lastModified());
}
} catch (URISyntaxException e) {
// in doubt return false
return false;
}
}
FileTimeStampChecker serializedTimeStampCheck = loadTimeStampCache();
if (serializedTimeStampCheck.equals(fileStampCheck)) {
context.logMessage(Diagnostic.Kind.OTHER, "XML parsing will be skipped due to unchanged xml files");
mappingFilesUnchanged = true;
} else {
saveTimeStampCache(fileStampCheck);
}
return mappingFilesUnchanged;
}
use of org.hibernate.jpamodelgen.util.FileTimeStampChecker in project hibernate-orm by hibernate.
the class JpaDescriptorParser method loadTimeStampCache.
private FileTimeStampChecker loadTimeStampCache() {
FileTimeStampChecker serializedTimeStampCheck = new FileTimeStampChecker();
File file = null;
try {
file = getSerializationTmpFile();
if (file.exists()) {
ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));
serializedTimeStampCheck = (FileTimeStampChecker) in.readObject();
in.close();
}
} catch (Exception e) {
// ignore - if the de-serialization failed we just have to keep parsing the xml
context.logMessage(Diagnostic.Kind.OTHER, "Error de-serializing " + file);
}
return serializedTimeStampCheck;
}
Aggregations