Package org.wildfly.prospero.galleon
Class ArtifactCache
- java.lang.Object
-
- org.wildfly.prospero.galleon.ArtifactCache
-
public class ArtifactCache extends Object
Manages artifact cache located ininstallationDir/CACHE_FOLDER. Cached artifacts are listed inCACHE_FOLDER/CACHE_FILENAME. Each artifact is identified by itsGAVand specifies an SHA-1 hash of the file and a relative path were the artifact can be found withininstallationDir. If the artifact cannot be found within Galleon-provisionedinstallationDir, the artifact can be added to theCACHE_FOLDER. The cache is rebuild during update and only current artifacts are stored.
-
-
Field Summary
Fields Modifier and Type Field Description static PathCACHE_FOLDER
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcache(org.wildfly.channel.MavenArtifact artifact)caches the artifact inCACHE_FOLDER.voidcache(org.wildfly.prospero.metadata.ManifestVersionRecord manifestRecord, ResolvedArtifactsStore resolvedArtifacts)detects and caches the manifests frommanifestRecordinCACHE_FOLDER.static voidcleanInstancesCache()Optional<File>getArtifact(String groupId, String artifactId, String extension, String classifier, String version)finds a file associated with theGAVin the localinstallationDir.static ArtifactCachegetInstance(Path installationDir)returns artifact cache located atinstallationDir/{code CACHE_FOLDER}voidrecord(org.wildfly.channel.MavenArtifact artifact, Path pathToArtifact)records file in the cache descriptor.
-
-
-
Field Detail
-
CACHE_FOLDER
public static final Path CACHE_FOLDER
-
-
Method Detail
-
getInstance
public static ArtifactCache getInstance(Path installationDir) throws IOException
returns artifact cache located atinstallationDir/{code CACHE_FOLDER}- Parameters:
installationDir-- Returns:
- Throws:
IOException- if the cache descriptor is corrupt and cannot be read
-
cleanInstancesCache
public static void cleanInstancesCache()
-
getArtifact
public Optional<File> getArtifact(String groupId, String artifactId, String extension, String classifier, String version)
finds a file associated with theGAVin the localinstallationDir. The file is only matched if it'sGAVis recorded in cache descriptor and the file has not been modified since the cache was created.- Parameters:
groupId-artifactId-extension-classifier-version-- Returns:
- empty
Optionalif the file has not been matched, otherwise the matchingFile
-
record
public void record(org.wildfly.channel.MavenArtifact artifact, Path pathToArtifact) throws IOExceptionrecords file in the cache descriptor. The recorded path is relative toinstallationDir- Parameters:
artifact- - artifact to be recordedpathToArtifact- - location in the installation where the artifact can be found- Throws:
IOException
-
cache
public void cache(org.wildfly.channel.MavenArtifact artifact) throws IOExceptioncaches the artifact inCACHE_FOLDER. The cached artifact is then recorded in the cache list.- Parameters:
artifact-- Throws:
IOException
-
cache
public void cache(org.wildfly.prospero.metadata.ManifestVersionRecord manifestRecord, ResolvedArtifactsStore resolvedArtifacts) throws IOExceptiondetects and caches the manifests frommanifestRecordinCACHE_FOLDER. The version and content of the manifest is resolved usingresolvedArtifacts. NOTE: only manifests identified by maven coordinates are cached.- Parameters:
manifestRecord- - record containing all manifest used in installation.resolvedArtifacts- - artifacts resolved during provisioning.- Throws:
IOException
-
-