Package org.eclipse.lemminx.uriresolver
Class CacheResourcesManager
java.lang.Object
org.eclipse.lemminx.uriresolver.CacheResourcesManager
Cache resources manager.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classClasspath resource to deploy into the lemminx cache -
Constructor Summary
ConstructorsConstructorDescriptionCacheResourcesManager(com.google.common.cache.Cache<String, CacheResourceDownloadedException> cache) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddProtocolForCache(String protocol) Add protocol for using cache when url will start with the given protocol.booleancanUseCache(String url) Returnstrueif cache is enabled and url comes from "http(s)" or "ftp" andfalseotherwise.voidRemove the cache directory (.lemminx/cache) if it exists.voidForce the givenurlto download.getResource(String resourceURI) static PathgetResourceCachePath(String resourceURI) static PathgetResourceCachePath(URI uri) static PathTry to get the cachedCacheResourcesManager.ResourceToDeploy.resourceCachePathin cache file system and if it is not found, create the file with the given content ofCacheResourcesManager.ResourceToDeploy.resourceFromClasspathstored in classpath.booleanReturns true if the external resources can be downloaded and false otherwise.booleanReturnstrueif cache must be used,falseotherwise.voidremoveProtocolForCache(String protocol) Remove protocol to avoid using cache when url will start with the given protocol.voidsetDownloadExternalResources(boolean downloadExternalResources) Set true if the external resources can be downloaded and false otherwise.voidsetUseCache(boolean useCache) Settrueif cache must be used,falseotherwise.
-
Constructor Details
-
CacheResourcesManager
public CacheResourcesManager() -
CacheResourcesManager
public CacheResourcesManager(com.google.common.cache.Cache<String, CacheResourceDownloadedException> cache)
-
-
Method Details
-
getResource
- Throws:
IOException
-
getResourceCachePath
- Throws:
IOException
-
getResourceCachePath
- Throws:
IOException
-
getResourceCachePath
public static Path getResourceCachePath(CacheResourcesManager.ResourceToDeploy resource) throws IOException Try to get the cachedCacheResourcesManager.ResourceToDeploy.resourceCachePathin cache file system and if it is not found, create the file with the given content ofCacheResourcesManager.ResourceToDeploy.resourceFromClasspathstored in classpath.- Parameters:
resource- the resource to deploy if needed.- Returns:
- the cached
CacheResourcesManager.ResourceToDeploy.resourceCachePathin cache file system. - Throws:
IOException
-
canUseCache
Returnstrueif cache is enabled and url comes from "http(s)" or "ftp" andfalseotherwise.- Parameters:
url-- Returns:
trueif cache is enabled and url comes from "http(s)" or "ftp" andfalseotherwise.
-
setUseCache
public void setUseCache(boolean useCache) Settrueif cache must be used,falseotherwise.- Parameters:
useCache-trueif cache must be used,falseotherwise.
-
isUseCache
public boolean isUseCache()Returnstrueif cache must be used,falseotherwise.- Returns:
trueif cache must be used,falseotherwise.
-
isDownloadExternalResources
public boolean isDownloadExternalResources()Returns true if the external resources can be downloaded and false otherwise.- Returns:
- true if the external resources can be downloaded and false otherwise.
-
setDownloadExternalResources
public void setDownloadExternalResources(boolean downloadExternalResources) Set true if the external resources can be downloaded and false otherwise.- Parameters:
downloadExternalResources- the external resources
-
evictCache
Remove the cache directory (.lemminx/cache) if it exists.- Throws:
IOException- if the delete of directory (.lemminx/cache) cannot be done.
-
addProtocolForCache
Add protocol for using cache when url will start with the given protocol.- Parameters:
protocol- the protocol to add.
-
removeProtocolForCache
Remove protocol to avoid using cache when url will start with the given protocol.- Parameters:
protocol- the protocol to remove.
-
forceDownloadExternalResource
Force the givenurlto download.- Parameters:
url- the url to download.
-