Class Cache

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

public class Cache extends Object
The Cache. - clear() -> void - cleanup() -> void - contains(cacheKey) -> boolean - isNewerThan(cacheKey, date) -> boolean - get(cacheKey) -> file - add(inputStream, downloadInfo) -> void - bestMatchingVersion(url, versionRange) -> versionId
  • Constructor Details

    • Cache

      public Cache()
  • Method Details

    • clearCache

      public static boolean clearCache()
      Clears the cache by deleting all content

      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.

      Returns:
      true if the cache could and was cleared
    • cleanCache

      public static void cleanCache()
      This will remove all old cache items.
    • getCacheFile

      public static File getCacheFile(URL resource, VersionId version)
      Returns the file for the locally cached contents of the resource. This method returns the file location only and does not download the resource. The latest version of the resource that matches the specified version will be returned.
      Parameters:
      resource - the resource URL
      version - the version of the local file
      Returns:
      the file location in the cache, or null if no versions cached
      Throws:
      IllegalArgumentException - if the resource is not cacheable
    • getCacheFile

      private static File getCacheFile(CacheKey key)
    • addToCache

      public static File addToCache(DownloadInfo infoFromRemote, InputStream unpackedStream) throws IOException
      Throws:
      IOException
    • invalidateExistingCacheFile

      public static void invalidateExistingCacheFile(URL resource, VersionId version)
      Invalidate the entry and make it eligible for removal.
      Parameters:
      resource - the resource URL
      version - the versions
      Throws:
      IllegalArgumentException - if the resource is not cacheable
    • invalidateExistingCacheFile

      private static void invalidateExistingCacheFile(CacheKey key)
    • deleteFromCache

      public static void deleteFromCache(ResourceInfo info)
    • deleteFromCache

      public static void deleteFromCache(URL resource, VersionString version)
    • isCached

      public static boolean isCached(URL resource, VersionId version)
      Returns whether there is a version of the URL contents in the cache.
      Parameters:
      resource - the resource URL
      version - the versions to check for
      Returns:
      whether the cache contains the version
      Throws:
      IllegalArgumentException - if the resource is not cacheable
    • isCached

      private static boolean isCached(CacheKey key)
    • getInfo

      public static ResourceInfo getInfo(URL resource, VersionId version)
    • getInfo

      private static ResourceInfo getInfo(CacheKey key)
    • isAnyCached

      public static boolean isAnyCached(URL resource, VersionString version)
      Returns true if the cache has a local copy of the contents of the URL matching the specified version.
      Parameters:
      resource - the resource URL
      version - the version to check for
      Returns:
      true if the source is in the cache
      Throws:
      IllegalArgumentException - if the source is not cacheable
    • getBestMatchingVersionInCache

      public static VersionId getBestMatchingVersionInCache(URL resource, VersionString version)
    • getAllVersionsInCache

      public static List<VersionId> getAllVersionsInCache(URL resourceHref)
    • isUpToDate

      public static boolean isUpToDate(URL resource, VersionId version, long lastModified)
      Returns whether there is a version of the URL contents in the cache and it is up to date. This method may not return immediately.
      Parameters:
      resource - the resource URL
      version - the versions to check for
      lastModified - time in millis since epoch of last modification
      Returns:
      whether the cache contains the version
      Throws:
      IllegalArgumentException - if the resource is not cacheable
    • isUpToDate

      private static boolean isUpToDate(CacheKey key, long lastModified)
    • assertLocationIsCacheable

      private static void assertLocationIsCacheable(URL location)
    • getJnlpCacheIds

      public static List<CacheIdInfo> getJnlpCacheIds()
      This method load all known IDs of applications
    • getDomainCacheIds

      public static List<CacheIdInfo> getDomainCacheIds()
      This method load all known IDs of applications
    • getCacheIds

      public static List<CacheIdInfo> getCacheIds(String filter)
      This method load all known IDs of applications and will gather all members, which share the id
      Parameters:
      filter - - regex to filter keys
    • deleteFromCache

      public static void deleteFromCache(String cacheId)
    • deleteFromCache

      public static void deleteFromCache(CacheIdInfo cacheId)