Class Cache
- java.lang.Object
-
- net.adoptopenjdk.icedteaweb.resources.cache.Cache
-
public class Cache extends java.lang.ObjectThe Cache. - clear() -> void - cleanup() -> void - contains(cacheKey) -> boolean - isNewerThan(cacheKey, date) -> boolean - get(cacheKey) -> file - add(inputStream, downloadInfo) -> void - bestMatchingVersion(url, versionRange) -> versionId
-
-
Constructor Summary
Constructors Constructor Description Cache()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.io.FileaddToCache(DownloadInfo infoFromRemote, java.io.InputStream unpackedStream)private static voidassertLocationIsCacheable(java.net.URL location)static voidcleanCache()This will remove all old cache items.static booleanclearCache()Clears the cache by deleting all contentstatic voiddeleteFromCache(java.lang.String cacheId)static voiddeleteFromCache(java.net.URL resource, VersionString version)static voiddeleteFromCache(CacheIdInfo cacheId)static voiddeleteFromCache(ResourceInfo info)static java.util.List<VersionId>getAllVersionsInCache(java.net.URL resourceHref)static VersionIdgetBestMatchingVersionInCache(java.net.URL resource, VersionString version)static java.io.FilegetCacheFile(java.net.URL resource, VersionId version)Returns the file for the locally cached contents of the resource.private static java.io.FilegetCacheFile(CacheKey key)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 idstatic java.util.List<CacheIdInfo>getDomainCacheIds()This method load all known IDs of applicationsstatic ResourceInfogetInfo(java.net.URL resource, VersionId version)private static ResourceInfogetInfo(CacheKey key)static java.util.List<CacheIdInfo>getJnlpCacheIds()This method load all known IDs of applicationsstatic voidinvalidateExistingCacheFile(java.net.URL resource, VersionId version)Invalidate the entry and make it eligible for removal.private static voidinvalidateExistingCacheFile(CacheKey key)static booleanisAnyCached(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.static booleanisCached(java.net.URL resource, VersionId version)Returns whether there is a version of the URL contents in the cache.private static booleanisCached(CacheKey key)static booleanisUpToDate(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.private static booleanisUpToDate(CacheKey key, long lastModified)
-
-
-
Method Detail
-
clearCache
public static boolean clearCache()
Clears the cache by deleting all contentNote: 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 resourceURLversion- the version of the local file- Returns:
- the file location in the cache, or
nullif 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 resourceURLversion- 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 resourceURLversion- 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)
-
getInfo
public static ResourceInfo getInfo(java.net.URL resource, VersionId version)
-
getInfo
private static ResourceInfo getInfo(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 URLversion- 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 resourceURLversion- the versions to check forlastModified- 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)
-
-