Class CacheImpl

java.lang.Object
net.adoptopenjdk.icedteaweb.resources.cache.CacheImpl

class CacheImpl extends Object
This class helps maintain the ordering of most recently use cache items across multiple jvm instances. The LRU information is stored as a properties file in the root of the file cache directory.
  • Field Details

  • Constructor Details

  • Method Details

    • getInstance

      static CacheImpl getInstance()
    • getCacheFile

      File getCacheFile(CacheKey key)
    • getCacheEntry

      private CacheIndexEntry getCacheEntry(CacheIndex idx, CacheKey key)
    • addToCache

      File addToCache(DownloadInfo info, InputStream inputStream) throws IOException
      Throws:
      IOException
    • createCacheEntry

      private CacheIndexEntry createCacheEntry(CacheIndex idx, CacheKey key)
    • makeNewCacheDir

      private File makeNewCacheDir()
    • createInfoFile

      private void createInfoFile(File dir)
    • getResourceInfo

      Optional<CachedFile> getResourceInfo(CacheKey key)
    • isCached

      boolean isCached(CacheKey key)
      Returns whether there is a version of the URL contents in the cache.
      Parameters:
      key - the key of the cache entry
      Returns:
      whether the cache contains the version
      Throws:
      IllegalArgumentException - if the resourceHref is not cacheable
    • isUpToDate

      boolean isUpToDate(CacheKey key, long lastModified)
      Returns whether there is a version of the URL contents in the cache and it is up to date.
      Parameters:
      key - the key of the cache entry
      lastModified - time in millis since epoch of last modification
      Returns:
      whether the cache contains the version
      Throws:
      IllegalArgumentException - if the resourceHref is not cacheable
    • getBestMatchingEntryInCache

      Optional<CacheIndexEntry> getBestMatchingEntryInCache(URL resourceHref, VersionString version)
    • getAllEntriesInCache

      List<CacheIndexEntry> getAllEntriesInCache(URL resourceHref)
      Return all valid cache entries with this URL, regardless of whether they have a version or not. They are not sorted.
      Parameters:
      resourceHref -
      Returns:
    • getCacheIds

      List<CacheIdInfo> getCacheIds(String filter, boolean includeJnlpPath, boolean includeDomain)
    • createPaneObjectArray

      private CacheFileInfoImpl createPaneObjectArray(CacheIndexEntry entry)
    • invalidateExistingCacheFile

      void invalidateExistingCacheFile(CacheKey key)
    • deleteFromCache

      void deleteFromCache(CacheKey key)
    • deleteFromCache

      void deleteFromCache(URL resourceHref, VersionString version)
    • deleteFromCache

      void deleteFromCache(CacheIdInfo cacheId)
    • createExtractor

      private Function<CacheIndexEntry, String> createExtractor(CacheIdInfo.CacheIdType idType)
    • deleteFilesFromCache

      private void deleteFilesFromCache(CacheIndexEntry entry)
    • clearCache

      boolean clearCache()
      Clears the cache by deleting all the Netx cache files

      Note: Because of how our caching system works, deleting jars of another javaws process is using them can be quite disastrous. Hence why Launcher creates lock files and we check for those by calling okToClearCache()

      Returns:
      true if the cache could be cleared and was cleared
    • deleteAll

      private void deleteAll(Collection<File> files)
    • deleteAll

      private void deleteAll(File... files)
    • deleteDir

      private void deleteDir(File file)
    • cleanCache

      void cleanCache()
      This will remove all old cache items.
    • collectAllEntryIdsFromFileSystem

      private Set<String> collectAllEntryIdsFromFileSystem(File[] levelOneDirs)
    • getMaxSizeInBytes

      private long getMaxSizeInBytes()
    • getCacheFile

      private File getCacheFile(CacheIndexEntry entry)
    • getInfoFile

      private CachedFile getInfoFile(CacheIndexEntry entry)
    • entryIdFromCacheDir

      private String entryIdFromCacheDir(File dir)
    • cacheDirFromEntryId

      private File cacheDirFromEntryId(String entryId)
    • getCacheFileName

      private String getCacheFileName(URL resourceHref)
    • extractFileNameFromUrl

      private String extractFileNameFromUrl(URL resourceHref)
    • cannotClearCache

      private boolean cannotClearCache()
    • okToClearCache

      private boolean okToClearCache()
      Returns a boolean indicating if it ok to clear the netx application cache at this point
      Returns:
      true if the cache can be cleared at this time without problems