org.apache.ivy.core.cache
Class CacheManager

java.lang.Object
  extended by org.apache.ivy.core.cache.CacheManager
All Implemented Interfaces:
RepositoryCacheManager, ResolutionCacheManager

public class CacheManager
extends java.lang.Object
implements RepositoryCacheManager, ResolutionCacheManager


Constructor Summary
CacheManager(CacheSettings settings, java.io.File cache)
           
 
Method Summary
 ResolvedModuleRevision cacheModuleDescriptor(DependencyResolver resolver, ResolvedResource mdRef, Artifact moduleArtifact, ResourceDownloader downloader, CacheMetadataOptions options)
           
 ArtifactDownloadReport download(Artifact artifact, ArtifactResourceResolver resourceResolver, ResourceDownloader resourceDownloader, CacheDownloadOptions options)
          Downloads an artifact to this cache.
 ResolvedModuleRevision findModuleInCache(ModuleRevisionId mrid, boolean validate, 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.io.File getArchiveFileInCache(Artifact artifact, ArtifactOrigin origin, boolean useOrigin)
          Returns a File object pointing to where the artifact can be found on the local file system, using or not the original location depending on the availability of origin information provided as parameter and the setting of useOrigin.
 java.lang.String getArchivePathInCache(Artifact artifact)
           
 java.lang.String getArchivePathInCache(Artifact artifact, ArtifactOrigin origin)
           
 java.io.File getConfigurationResolveReportInCache(java.lang.String resolveId, java.lang.String conf)
           
 java.io.File[] getConfigurationResolveReportsInCache(java.lang.String resolveId)
           
static CacheManager getInstance(CacheSettings settings)
           
static CacheManager getInstance(CacheSettings settings, java.io.File cache)
           
 java.io.File getIvyFileInCache(ModuleRevisionId mrid)
           
 LockStrategy getLockStrategy()
           
 Artifact getOriginalMetadataArtifact(Artifact moduleArtifact)
           
 java.io.File getRepositoryCacheRoot()
           
 java.io.File getResolutionCacheRoot()
           
 java.io.File getResolvedIvyFileInCache(ModuleRevisionId mrid)
           
 java.io.File getResolvedIvyPropertiesInCache(ModuleRevisionId mrid)
           
 ArtifactOrigin getSavedArtifactOrigin(Artifact artifact)
           
 void originalToCachedModuleDescriptor(DependencyResolver resolver, ResolvedResource orginalMetadataRef, Artifact requestedMetadataArtifact, ModuleDescriptor md, ModuleDescriptorWriter writer)
           
 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 setLockStrategy(LockStrategy lockStrategy)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CacheManager

public CacheManager(CacheSettings settings,
                    java.io.File cache)
Method Detail

getInstance

public static CacheManager getInstance(CacheSettings settings,
                                       java.io.File cache)

getInstance

public static CacheManager getInstance(CacheSettings settings)

getResolvedIvyFileInCache

public java.io.File getResolvedIvyFileInCache(ModuleRevisionId mrid)
Specified by:
getResolvedIvyFileInCache in interface ResolutionCacheManager

getResolvedIvyPropertiesInCache

public java.io.File getResolvedIvyPropertiesInCache(ModuleRevisionId mrid)
Specified by:
getResolvedIvyPropertiesInCache in interface ResolutionCacheManager

getConfigurationResolveReportInCache

public java.io.File getConfigurationResolveReportInCache(java.lang.String resolveId,
                                                         java.lang.String conf)
Specified by:
getConfigurationResolveReportInCache in interface ResolutionCacheManager

getConfigurationResolveReportsInCache

public java.io.File[] getConfigurationResolveReportsInCache(java.lang.String resolveId)
Specified by:
getConfigurationResolveReportsInCache in interface ResolutionCacheManager

getIvyFileInCache

public java.io.File getIvyFileInCache(ModuleRevisionId mrid)
Specified by:
getIvyFileInCache in interface RepositoryCacheManager

getArchiveFileInCache

public java.io.File getArchiveFileInCache(Artifact artifact)
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

Specified by:
getArchiveFileInCache in interface RepositoryCacheManager

getArchiveFileInCache

public 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. 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

Specified by:
getArchiveFileInCache in interface RepositoryCacheManager

getArchiveFileInCache

public java.io.File getArchiveFileInCache(Artifact artifact,
                                          ArtifactOrigin origin,
                                          boolean useOrigin)
Returns a File object pointing to where the artifact can be found on the local file system, using or not the original location depending on the availability of origin information provided as parameter and the setting of useOrigin. If useOrigin is false, this method will always return the file in the cache.

Specified by:
getArchiveFileInCache in interface RepositoryCacheManager

getArchivePathInCache

public java.lang.String getArchivePathInCache(Artifact artifact)
Specified by:
getArchivePathInCache in interface RepositoryCacheManager

getArchivePathInCache

public java.lang.String getArchivePathInCache(Artifact artifact,
                                              ArtifactOrigin origin)
Specified by:
getArchivePathInCache in interface RepositoryCacheManager

saveResolvers

public 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)

Specified by:
saveResolvers in interface RepositoryCacheManager
Parameters:
md - the module descriptor resolved
name - artifact resolver name

getSavedArtifactOrigin

public ArtifactOrigin getSavedArtifactOrigin(Artifact artifact)
Specified by:
getSavedArtifactOrigin in interface RepositoryCacheManager

findModuleInCache

public ResolvedModuleRevision findModuleInCache(ModuleRevisionId mrid,
                                                boolean validate,
                                                java.lang.String expectedResolver)
Description copied from interface: RepositoryCacheManager
Search a module descriptor in cache for a mrid

Specified by:
findModuleInCache in interface RepositoryCacheManager
Parameters:
mrid - the id of the module to search
validate - true to validate ivy file found in cache before returning
expectedResolver - 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

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getRepositoryCacheRoot

public java.io.File getRepositoryCacheRoot()
Specified by:
getRepositoryCacheRoot in interface RepositoryCacheManager

getResolutionCacheRoot

public java.io.File getResolutionCacheRoot()
Specified by:
getResolutionCacheRoot in interface ResolutionCacheManager

getLockStrategy

public LockStrategy getLockStrategy()

setLockStrategy

public void setLockStrategy(LockStrategy lockStrategy)

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 interface RepositoryCacheManager
Parameters:
artifact - the artifact to download
resourceResolver - a resource resolver to use if the artifact needs to be resolved to a Resource for downloading
resourceDownloader - a resource downloader to use if actual download of the resource is needed
options - a set of options to adjust the download
Returns:
a report indicating how the download was performed

originalToCachedModuleDescriptor

public void originalToCachedModuleDescriptor(DependencyResolver resolver,
                                             ResolvedResource orginalMetadataRef,
                                             Artifact requestedMetadataArtifact,
                                             ModuleDescriptor md,
                                             ModuleDescriptorWriter writer)
Specified by:
originalToCachedModuleDescriptor in interface RepositoryCacheManager

cacheModuleDescriptor

public ResolvedModuleRevision cacheModuleDescriptor(DependencyResolver resolver,
                                                    ResolvedResource mdRef,
                                                    Artifact moduleArtifact,
                                                    ResourceDownloader downloader,
                                                    CacheMetadataOptions options)
                                             throws java.text.ParseException
Specified by:
cacheModuleDescriptor in interface RepositoryCacheManager
Throws:
java.text.ParseException

getOriginalMetadataArtifact

public Artifact getOriginalMetadataArtifact(Artifact moduleArtifact)