Class Cache


  • public class Cache
    extends java.lang.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 Detail

      • Cache

        public Cache()
    • Method Detail

      • 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 java.io.File getCacheFile​(java.net.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:
        java.lang.IllegalArgumentException - if the resource is not cacheable
      • getCacheFile

        private static java.io.File getCacheFile​(CacheKey key)
      • addToCache

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

        public static void invalidateExistingCacheFile​(java.net.URL resource,
                                                       VersionId version)
        Invalidate the entry and make it eligible for removal.
        Parameters:
        resource - the resource URL
        version - the versions
        Throws:
        java.lang.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​(java.net.URL resource,
                                           VersionString version)
      • isCached

        public static boolean isCached​(java.net.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:
        java.lang.IllegalArgumentException - if the resource is not cacheable
      • isCached

        private static boolean isCached​(CacheKey key)
      • isAnyCached

        public static boolean isAnyCached​(java.net.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:
        java.lang.IllegalArgumentException - if the source is not cacheable
      • getBestMatchingVersionInCache

        public static VersionId getBestMatchingVersionInCache​(java.net.URL resource,
                                                              VersionString version)
      • getAllVersionsInCache

        public static java.util.List<VersionId> getAllVersionsInCache​(java.net.URL resourceHref)
      • isUpToDate

        public static boolean isUpToDate​(java.net.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:
        java.lang.IllegalArgumentException - if the resource is not cacheable
      • isUpToDate

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

        private static void assertLocationIsCacheable​(java.net.URL location)
      • getJnlpCacheIds

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

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

        public static java.util.List<CacheIdInfo> getCacheIds​(java.lang.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​(java.lang.String cacheId)
      • deleteFromCache

        public static void deleteFromCache​(CacheIdInfo cacheId)