Package org.apache.ivy.core.cache
Class DefaultRepositoryCacheManager
java.lang.Object
org.apache.ivy.core.cache.DefaultRepositoryCacheManager
- All Implemented Interfaces:
RepositoryCacheManager
,IvySettingsAware
public class DefaultRepositoryCacheManager
extends Object
implements RepositoryCacheManager, IvySettingsAware
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultRepositoryCacheManager
(String name, IvySettings settings, File basedir) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addConfiguredTtl
(Map<String, String> attributes) void
addTTL
(Map<String, String> attributes, PatternMatcher matcher, long duration) final void
assertInsideCache
(File fileInCache) cacheModuleDescriptor
(DependencyResolver resolver, ResolvedResource mdRef, DependencyDescriptor dd, Artifact moduleArtifact, ResourceDownloader downloader, CacheMetadataOptions options) Caches an original module descriptor.void
clean()
Cleans the whole cache.download
(Artifact artifact, ArtifactResourceResolver resourceResolver, ResourceDownloader resourceDownloader, CacheDownloadOptions options) Downloads an artifact to this cache.downloadRepositoryResource
(Resource resource, String name, String type, String extension, CacheResourceOptions options, Repository repository) Download some repository resource and put it in the cache.void
findModuleInCache
(DependencyDescriptor dd, ModuleRevisionId requestedRevisionId, CacheMetadataOptions options, String expectedResolver) Search a module descriptor in cache for a mridgetArchiveFileInCache
(Artifact artifact) Returns a File object pointing to where the artifact can be found on the local file system.getArchiveFileInCache
(Artifact artifact, ArtifactOrigin origin) Returns a File object pointing to where the artifact can be found on the local file system.getArchivePathInCache
(Artifact artifact) getArchivePathInCache
(Artifact artifact, ArtifactOrigin origin) long
org.apache.ivy.core.cache.ModuleDescriptorMemoryCache
protected ModuleDescriptorParser
getModuleDescriptorParser
(File moduleDescriptorFile) Choose write module descriptor parser for a given moduleDescriptorgetName()
Returns the name of the repository cache manager.getOriginalMetadataArtifact
(Artifact moduleArtifact) getSavedArtifactOrigin
(Artifact artifact) Returns the artifact origin of the given artifact as saved in this cache.long
getTTL
(ModuleRevisionId mrid) boolean
True if this cache should check lastmodified date to know if ivy files are up to date.boolean
True if this cache should use artifacts original location when possible, false if they should be copied to cache.void
originalToCachedModuleDescriptor
(DependencyResolver resolver, ResolvedResource originalMetadataRef, Artifact requestedMetadataArtifact, ResolvedModuleRevision rmr, ModuleDescriptorWriter writer) Stores a standardized version of an original module descriptor in the cache for later use.void
saveResolvedRevision
(String resolverName, ModuleRevisionId mrid, String revision) Caches a dynamic revision constraint resolution for a specific resolver.void
saveResolvedRevision
(ModuleRevisionId mrid, String revision) Deprecated.void
saveResolvers
(ModuleDescriptor md, String metadataResolverName, String artifactResolverName) Saves the information of which resolver was used to resolve a md, so that this info can be retrieve later (even after a jvm restart) by getSavedArtResolverName(ModuleDescriptor md)void
setArtifactPattern
(String artifactPattern) void
setBasedir
(File cache) void
setChangingMatcher
(String changingMatcherName) void
setChangingPattern
(String changingPattern) void
setCheckmodified
(boolean check) void
setDataFilePattern
(String dataFilePattern) void
setDefaultTTL
(long defaultTTL) void
setDefaultTTL
(String defaultTTL) void
setIvyPattern
(String ivyPattern) void
setLockStrategy
(String lockStrategyName) void
setLockStrategy
(LockStrategy lockStrategy) void
setMemorySize
(int size) void
void
setSettings
(IvySettings settings) void
setUseOrigin
(boolean b) toString()
-
Constructor Details
-
DefaultRepositoryCacheManager
public DefaultRepositoryCacheManager() -
DefaultRepositoryCacheManager
-
-
Method Details
-
getSettings
-
setSettings
- Specified by:
setSettings
in interfaceIvySettingsAware
-
getIvyFileInCache
-
getIvyPattern
-
getArtifactPattern
-
setArtifactPattern
-
getBasedir
-
setBasedir
-
getDefaultTTL
public long getDefaultTTL() -
setDefaultTTL
public void setDefaultTTL(long defaultTTL) -
setDefaultTTL
-
getDataFilePattern
-
setDataFilePattern
-
setIvyPattern
-
getName
Description copied from interface:RepositoryCacheManager
Returns the name of the repository cache manager.- Specified by:
getName
in interfaceRepositoryCacheManager
- Returns:
- the name of the repository cache manager.
-
setName
-
getChangingMatcherName
-
setChangingMatcher
-
getChangingPattern
-
setChangingPattern
-
addTTL
-
addConfiguredTtl
-
setMemorySize
public void setMemorySize(int size) -
getMemoryCache
public org.apache.ivy.core.cache.ModuleDescriptorMemoryCache getMemoryCache() -
isCheckmodified
public boolean isCheckmodified()True if this cache should check lastmodified date to know if ivy files are up to date.- Returns:
- boolean
-
setCheckmodified
public void setCheckmodified(boolean check) -
isUseOrigin
public boolean isUseOrigin()True if this cache should use artifacts original location when possible, false if they should be copied to cache.- Returns:
- boolean
-
setUseOrigin
public void setUseOrigin(boolean b) -
getArchiveFileInCache
Returns a File object pointing to where the artifact can be found on the local file system. This is usually in the cache, but it can be directly in the repository if it is local and if the resolve has been done with useOrigin = true- Parameters:
artifact
- Artifact- Returns:
- File
-
getArchiveFileInCache
Returns a File object pointing to where the artifact can be found on the local file system. This is usually in the cache, but it can be directly in the repository if it is local and if the resolve has been done with useOrigin = true- Parameters:
artifact
- Artifactorigin
- ArtifactOrigin- Returns:
- File
-
getArchivePathInCache
-
getArchivePathInCache
-
saveResolvers
public void saveResolvers(ModuleDescriptor md, String metadataResolverName, String artifactResolverName) Saves the information of which resolver was used to resolve a md, so that this info can be retrieve later (even after a jvm restart) by getSavedArtResolverName(ModuleDescriptor md)- Specified by:
saveResolvers
in interfaceRepositoryCacheManager
- Parameters:
md
- the module descriptor resolvedmetadataResolverName
- metadata resolver nameartifactResolverName
- artifact resolver name
-
getSavedArtifactOrigin
Description copied from interface:RepositoryCacheManager
Returns the artifact origin of the given artifact as saved in this cache.If the origin is unknown, the returned ArtifactOrigin instance will return true when
ArtifactOrigin.isUnknown(ArtifactOrigin)
is called.- Specified by:
getSavedArtifactOrigin
in interfaceRepositoryCacheManager
- Parameters:
artifact
- the artifact for which the saved artifact origin should be returned.- Returns:
- the artifact origin of the given artifact as saved in this cache
-
findModuleInCache
public ResolvedModuleRevision findModuleInCache(DependencyDescriptor dd, ModuleRevisionId requestedRevisionId, CacheMetadataOptions options, String expectedResolver) Description copied from interface:RepositoryCacheManager
Search a module descriptor in cache for a mrid- Specified by:
findModuleInCache
in interfaceRepositoryCacheManager
- Parameters:
dd
- the dependency descriptor identifying the module to searchrequestedRevisionId
- the requested dependency module revision id identifying the module to searchoptions
- options on how caching should be handledexpectedResolver
- the resolver with which the md in cache must have been resolved to be returned, null if this doesn't matter- Returns:
- the ResolvedModuleRevision corresponding to the module found, null if none correct has been found in cache
-
getModuleDescriptorParser
Choose write module descriptor parser for a given moduleDescriptor- Parameters:
moduleDescriptorFile
- a given module descriptor- Returns:
- ModuleDescriptorParser
-
saveResolvedRevision
Deprecated.Description copied from interface:RepositoryCacheManager
Caches a dynamic revision constraint resolution.- Specified by:
saveResolvedRevision
in interfaceRepositoryCacheManager
- Parameters:
mrid
- the dynamic module revision idrevision
- the resolved revision
-
saveResolvedRevision
Description copied from interface:RepositoryCacheManager
Caches a dynamic revision constraint resolution for a specific resolver.- Specified by:
saveResolvedRevision
in interfaceRepositoryCacheManager
- Parameters:
resolverName
- the resolver in which this dynamic revision was resolvedmrid
- the dynamic module revision idrevision
- the resolved revision
-
getTTL
-
toString
-
getRepositoryCacheRoot
-
getLockStrategy
-
setLockStrategy
-
setLockStrategy
-
download
public ArtifactDownloadReport download(Artifact artifact, ArtifactResourceResolver resourceResolver, ResourceDownloader resourceDownloader, CacheDownloadOptions options) Description copied from interface:RepositoryCacheManager
Downloads an artifact to this cache.- Specified by:
download
in interfaceRepositoryCacheManager
- Parameters:
artifact
- the artifact to downloadresourceResolver
- a resource resolver to use if the artifact needs to be resolved to a Resource for downloadingresourceDownloader
- a resource downloader to use if actual download of the resource is neededoptions
- a set of options to adjust the download- Returns:
- a report indicating how the download was performed
-
downloadRepositoryResource
public ArtifactDownloadReport downloadRepositoryResource(Resource resource, String name, String type, String extension, CacheResourceOptions options, Repository repository) Description copied from interface:RepositoryCacheManager
Download some repository resource and put it in the cache.If the cached version is considered enough up to date, no downloading is done.
- Specified by:
downloadRepositoryResource
in interfaceRepositoryCacheManager
- Parameters:
resource
- the resource of the file to put in cachename
- the descriptive name of the resource (helps while manually looking into the cache files)type
- the type of the resource (helps while manually looking into the cache files)extension
- the extension of the resource (helps while manually looking into the cache files)options
- a set of options to adjust the downloadrepository
- the repository which resolve the content of the resource- Returns:
- a report indicating how the download was performed
-
originalToCachedModuleDescriptor
public void originalToCachedModuleDescriptor(DependencyResolver resolver, ResolvedResource originalMetadataRef, Artifact requestedMetadataArtifact, ResolvedModuleRevision rmr, ModuleDescriptorWriter writer) Description copied from interface:RepositoryCacheManager
Stores a standardized version of an original module descriptor in the cache for later use.- Specified by:
originalToCachedModuleDescriptor
in interfaceRepositoryCacheManager
- Parameters:
resolver
- the dependency resolver from which the cache request comes fromoriginalMetadataRef
- a resolved resource pointing to the remote original module descriptorrequestedMetadataArtifact
- the module descriptor artifact as requested originallyrmr
- theResolvedModuleRevision
representing the local cached module descriptorwriter
- aModuleDescriptorWriter
able to write the module descriptor to a stream.
-
cacheModuleDescriptor
public ResolvedModuleRevision cacheModuleDescriptor(DependencyResolver resolver, ResolvedResource mdRef, DependencyDescriptor dd, Artifact moduleArtifact, ResourceDownloader downloader, CacheMetadataOptions options) throws ParseException Description copied from interface:RepositoryCacheManager
Caches an original module descriptor.After this call, the original module descriptor file (with no modification nor conversion) should be available as a local file.
- Specified by:
cacheModuleDescriptor
in interfaceRepositoryCacheManager
- Parameters:
resolver
- the dependency resolver from which the cache request comes frommdRef
- a resolved resource pointing to the remote original module descriptordd
- the dependency descriptor for which the module descriptor should be cachedmoduleArtifact
- the module descriptor artifact as requested originallydownloader
- a ResourceDownloader able to download the original module descriptor resource if required by this cache implementationoptions
- options to apply to cache this module descriptor- Returns:
- a
ResolvedModuleRevision
representing the local cached module descriptor, or null if it failed - Throws:
ParseException
- if an exception occurred while parsing the module descriptor
-
getOriginalMetadataArtifact
-
clean
public void clean()Description copied from interface:RepositoryCacheManager
Cleans the whole cache.- Specified by:
clean
in interfaceRepositoryCacheManager
-
dumpSettings
public void dumpSettings() -
assertInsideCache
- Throws:
IllegalArgumentException
- if the given path points outside of the cache.
-