public class DefaultRepositoryCacheManager extends java.lang.Object implements RepositoryCacheManager, IvySettingsAware
Constructor and Description |
---|
DefaultRepositoryCacheManager() |
DefaultRepositoryCacheManager(java.lang.String name,
IvySettings settings,
java.io.File basedir) |
Modifier and Type | Method and Description |
---|---|
void |
addConfiguredTtl(java.util.Map attributes) |
void |
addTTL(java.util.Map attributes,
PatternMatcher matcher,
long duration) |
ResolvedModuleRevision |
cacheModuleDescriptor(DependencyResolver resolver,
ResolvedResource mdRef,
DependencyDescriptor dd,
Artifact moduleArtifact,
ResourceDownloader downloader,
CacheMetadataOptions options)
Caches an original module descriptor.
|
void |
clean()
Cleans the whole cache.
|
ArtifactDownloadReport |
download(Artifact artifact,
ArtifactResourceResolver resourceResolver,
ResourceDownloader resourceDownloader,
CacheDownloadOptions options)
Downloads an artifact to this cache.
|
ArtifactDownloadReport |
downloadRepositoryResource(Resource resource,
java.lang.String name,
java.lang.String type,
java.lang.String extension,
CacheResourceOptions options,
Repository repository)
Download some repository resource and put it in the cache.
|
void |
dumpSettings() |
ResolvedModuleRevision |
findModuleInCache(DependencyDescriptor dd,
ModuleRevisionId requestedRevisionId,
CacheMetadataOptions options,
java.lang.String expectedResolver)
Search a module descriptor in cache for a mrid
|
java.io.File |
getArchiveFileInCache(Artifact artifact)
Returns a File object pointing to where the artifact can be found on the local file system.
|
java.io.File |
getArchiveFileInCache(Artifact artifact,
ArtifactOrigin origin)
Returns a File object pointing to where the artifact can be found on the local file system.
|
java.lang.String |
getArchivePathInCache(Artifact artifact) |
java.lang.String |
getArchivePathInCache(Artifact artifact,
ArtifactOrigin origin) |
java.lang.String |
getArtifactPattern() |
java.io.File |
getBasedir() |
java.lang.String |
getChangingMatcherName() |
java.lang.String |
getChangingPattern() |
java.lang.String |
getDataFilePattern() |
long |
getDefaultTTL() |
java.io.File |
getIvyFileInCache(ModuleRevisionId mrid) |
java.lang.String |
getIvyPattern() |
LockStrategy |
getLockStrategy() |
org.apache.ivy.core.cache.ModuleDescriptorMemoryCache |
getMemoryCache() |
protected ModuleDescriptorParser |
getModuleDescriptorParser(java.io.File moduleDescriptorFile)
Choose write module descriptor parser for a given moduleDescriptor
|
java.lang.String |
getName()
Returns the name of the repository cache manager.
|
Artifact |
getOriginalMetadataArtifact(Artifact moduleArtifact) |
java.io.File |
getRepositoryCacheRoot() |
ArtifactOrigin |
getSavedArtifactOrigin(Artifact artifact)
Returns the artifact origin of the given artifact as saved in this cache.
|
IvySettings |
getSettings() |
long |
getTTL(ModuleRevisionId mrid) |
boolean |
isCheckmodified()
True if this cache should check lastmodified date to know if ivy files are up to date.
|
boolean |
isUseOrigin()
True if this cache should use artifacts original location when possible, false if they should
be copied to cache.
|
void |
originalToCachedModuleDescriptor(DependencyResolver resolver,
ResolvedResource orginalMetadataRef,
Artifact requestedMetadataArtifact,
ResolvedModuleRevision rmr,
ModuleDescriptorWriter writer)
Stores a standardized version of an original module descriptor in the cache for later use.
|
void |
saveResolvedRevision(ModuleRevisionId mrid,
java.lang.String revision)
Caches a dynamic revision constraint resolution.
|
void |
saveResolvers(ModuleDescriptor md,
java.lang.String metadataResolverName,
java.lang.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(java.lang.String artifactPattern) |
void |
setBasedir(java.io.File cache) |
void |
setChangingMatcher(java.lang.String changingMatcherName) |
void |
setChangingPattern(java.lang.String changingPattern) |
void |
setCheckmodified(boolean check) |
void |
setDataFilePattern(java.lang.String dataFilePattern) |
void |
setDefaultTTL(long defaultTTL) |
void |
setDefaultTTL(java.lang.String defaultTTL) |
void |
setIvyPattern(java.lang.String ivyPattern) |
void |
setLockStrategy(LockStrategy lockStrategy) |
void |
setLockStrategy(java.lang.String lockStrategyName) |
void |
setMemorySize(int size) |
void |
setName(java.lang.String name) |
void |
setSettings(IvySettings settings) |
void |
setUseOrigin(boolean b) |
java.lang.String |
toString() |
public DefaultRepositoryCacheManager()
public DefaultRepositoryCacheManager(java.lang.String name, IvySettings settings, java.io.File basedir)
public IvySettings getSettings()
public void setSettings(IvySettings settings)
setSettings
in interface IvySettingsAware
public java.io.File getIvyFileInCache(ModuleRevisionId mrid)
public java.lang.String getIvyPattern()
public java.lang.String getArtifactPattern()
public void setArtifactPattern(java.lang.String artifactPattern)
public java.io.File getBasedir()
public void setBasedir(java.io.File cache)
public long getDefaultTTL()
public void setDefaultTTL(long defaultTTL)
public void setDefaultTTL(java.lang.String defaultTTL)
public java.lang.String getDataFilePattern()
public void setDataFilePattern(java.lang.String dataFilePattern)
public void setIvyPattern(java.lang.String ivyPattern)
public java.lang.String getName()
RepositoryCacheManager
getName
in interface RepositoryCacheManager
public void setName(java.lang.String name)
public java.lang.String getChangingMatcherName()
public void setChangingMatcher(java.lang.String changingMatcherName)
public java.lang.String getChangingPattern()
public void setChangingPattern(java.lang.String changingPattern)
public void addTTL(java.util.Map attributes, PatternMatcher matcher, long duration)
public void addConfiguredTtl(java.util.Map attributes)
public void setMemorySize(int size)
public org.apache.ivy.core.cache.ModuleDescriptorMemoryCache getMemoryCache()
public boolean isCheckmodified()
public void setCheckmodified(boolean check)
public boolean isUseOrigin()
public void setUseOrigin(boolean b)
public java.io.File getArchiveFileInCache(Artifact artifact)
public java.io.File getArchiveFileInCache(Artifact artifact, ArtifactOrigin origin)
public java.lang.String getArchivePathInCache(Artifact artifact)
public java.lang.String getArchivePathInCache(Artifact artifact, ArtifactOrigin origin)
public void saveResolvers(ModuleDescriptor md, java.lang.String metadataResolverName, java.lang.String artifactResolverName)
saveResolvers
in interface RepositoryCacheManager
md
- the module descriptor resolvedname
- artifact resolver namepublic ArtifactOrigin getSavedArtifactOrigin(Artifact artifact)
RepositoryCacheManager
If the origin is unknown, the returned ArtifactOrigin instance will return true when
ArtifactOrigin.isUnknown(ArtifactOrigin)
is called.
getSavedArtifactOrigin
in interface RepositoryCacheManager
artifact
- the artifact for which the saved artifact origin should be returned.public ResolvedModuleRevision findModuleInCache(DependencyDescriptor dd, ModuleRevisionId requestedRevisionId, CacheMetadataOptions options, java.lang.String expectedResolver)
RepositoryCacheManager
findModuleInCache
in interface RepositoryCacheManager
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 matterprotected ModuleDescriptorParser getModuleDescriptorParser(java.io.File moduleDescriptorFile)
moduleDescriptorFile
- a given module descriptorpublic void saveResolvedRevision(ModuleRevisionId mrid, java.lang.String revision)
RepositoryCacheManager
saveResolvedRevision
in interface RepositoryCacheManager
mrid
- the dynamic module revision idrevision
- the resolved revisionpublic long getTTL(ModuleRevisionId mrid)
public java.lang.String toString()
toString
in class java.lang.Object
public java.io.File getRepositoryCacheRoot()
public LockStrategy getLockStrategy()
public void setLockStrategy(LockStrategy lockStrategy)
public void setLockStrategy(java.lang.String lockStrategyName)
public ArtifactDownloadReport download(Artifact artifact, ArtifactResourceResolver resourceResolver, ResourceDownloader resourceDownloader, CacheDownloadOptions options)
RepositoryCacheManager
download
in interface RepositoryCacheManager
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 downloadpublic ArtifactDownloadReport downloadRepositoryResource(Resource resource, java.lang.String name, java.lang.String type, java.lang.String extension, CacheResourceOptions options, Repository repository)
RepositoryCacheManager
If the cached version is considered enough up to date, no downloading is done.
downloadRepositoryResource
in interface RepositoryCacheManager
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 resourcepublic void originalToCachedModuleDescriptor(DependencyResolver resolver, ResolvedResource orginalMetadataRef, Artifact requestedMetadataArtifact, ResolvedModuleRevision rmr, ModuleDescriptorWriter writer)
RepositoryCacheManager
originalToCachedModuleDescriptor
in interface RepositoryCacheManager
resolver
- the dependency resolver from which the cache request comes fromorginalMetadataRef
- a resolved resource pointing to the remote original module descriptorrequestedMetadataArtifact
- the module descriptor artifact as requested originallyrmr
- the ResolvedModuleRevision
representing the local cached module descriptorwriter
- a ModuleDescriptorWriter
able to write the module descriptor to a stream.public ResolvedModuleRevision cacheModuleDescriptor(DependencyResolver resolver, ResolvedResource mdRef, DependencyDescriptor dd, Artifact moduleArtifact, ResourceDownloader downloader, CacheMetadataOptions options) throws java.text.ParseException
RepositoryCacheManager
After this call, the original module descriptor file (with no modification nor conversion) should be available as a local file.
cacheModuleDescriptor
in interface RepositoryCacheManager
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 descriptorResolvedModuleRevision
representing the local cached module descriptor, or
null if it failedjava.text.ParseException
- if an exception occurred while parsing the module descriptorpublic void clean()
RepositoryCacheManager
clean
in interface RepositoryCacheManager
public void dumpSettings()