} else {
packages = Collections.emptySet();
}
final boolean cacheDoesNotExist = CollectionUtils.isEmpty(packages);
final PackageCacheMode packageCacheMode = configuration.getSystemPackageCacheMode();
if (packageCacheMode.isReadFromCache() == false || cacheDoesNotExist || !validCache) {
packages = packageScanner.scanWebApplicationPackages();
}
if (packageCacheMode.isForceWriteToCache() || (cacheDoesNotExist && packageCacheMode.isWriteToCache())) {
writeCachedPackages(packages);
}
if (packageCacheMode.isWriteToCache() == false) {
final File cacheFile = configuration.getSystemPackageCache();
if (cacheFile.isFile()) {
cacheFile.delete();
}
}