Class CacheIndexHolder
- java.lang.Object
-
- net.adoptopenjdk.icedteaweb.resources.cache.CacheIndexHolder
-
class CacheIndexHolder extends java.lang.ObjectHolder of the cached LeastRecentlyUsedCacheIndex data. The responsibility of this class is to make sure that access to the content of the LeastRecentlyUsedCacheIndex is synchronized and any changes are written back to the file system.
-
-
Field Summary
Fields Modifier and Type Field Description private CacheIndexFilecachedCacheFileprivate static LoggerLOGprivate InfrastructureFileDescriptorrecentlyUsed
-
Constructor Summary
Constructors Constructor Description CacheIndexHolder(InfrastructureFileDescriptor recentlyUsed)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.StringconvertOldId(java.lang.String id)private CacheIndexFilegetCacheFile()(package private) <T> TgetSynchronized(java.util.function.Function<CacheIndex,T> action)Executes the function passed in action in a synchronized fashion to allow exclusive access to the index.private CacheIndexload(CacheIndexFile cacheFile)Loads the data from the properties file into an index.private CacheIndexFileloadOldIndex()private CacheIndexFilelockCacheFile()Lock the properties file to have exclusive access.private voidpersistChanges(CacheIndexFile cacheFile)Write file to disk.(package private) voidrunSynchronized(java.util.function.Consumer<CacheIndex> action)Executes the code passed in action in a synchronized fashion to allow exclusive access to the index.private voidunlockCacheFile(CacheIndexFile cacheFile)Unlock the properties file.
-
-
-
Field Detail
-
LOG
private static final Logger LOG
-
recentlyUsed
private final InfrastructureFileDescriptor recentlyUsed
-
cachedCacheFile
private CacheIndexFile cachedCacheFile
-
-
Constructor Detail
-
CacheIndexHolder
CacheIndexHolder(InfrastructureFileDescriptor recentlyUsed)
-
-
Method Detail
-
runSynchronized
void runSynchronized(java.util.function.Consumer<CacheIndex> action)
Executes the code passed in action in a synchronized fashion to allow exclusive access to the index.
-
getSynchronized
<T> T getSynchronized(java.util.function.Function<CacheIndex,T> action)
Executes the function passed in action in a synchronized fashion to allow exclusive access to the index.- Returns:
- the result of the passed function.
-
lockCacheFile
private CacheIndexFile lockCacheFile()
Lock the properties file to have exclusive access.
-
unlockCacheFile
private void unlockCacheFile(CacheIndexFile cacheFile)
Unlock the properties file.
-
load
private CacheIndex load(CacheIndexFile cacheFile)
Loads the data from the properties file into an index.
-
persistChanges
private void persistChanges(CacheIndexFile cacheFile)
Write file to disk.
-
getCacheFile
private CacheIndexFile getCacheFile()
- Returns:
- the recentlyUsedPropertiesFile
-
loadOldIndex
private CacheIndexFile loadOldIndex()
-
convertOldId
private java.lang.String convertOldId(java.lang.String id)
-
-