Class ArtifactCache

java.lang.Object
org.wildfly.prospero.galleon.ArtifactCache

public class ArtifactCache extends Object
Manages artifact cache located in installationDir/CACHE_FOLDER. Cached artifacts are listed in CACHE_FOLDER/CACHE_FILENAME. Each artifact is identified by its GAV and specifies an SHA-1 hash of the file and a relative path were the artifact can be found within installationDir. If the artifact cannot be found within Galleon-provisioned installationDir, the artifact can be added to the CACHE_FOLDER. The cache is rebuild during update and only current artifacts are stored.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Path
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    cache(org.wildfly.channel.MavenArtifact artifact)
    caches the artifact in CACHE_FOLDER.
    void
    cache(org.wildfly.prospero.metadata.ManifestVersionRecord manifestRecord, org.eclipse.aether.repository.LocalRepositoryManager localRepositoryManager)
    detects and caches the manifests from manifestRecord in CACHE_FOLDER.
    static void
     
    getArtifact(String groupId, String artifactId, String extension, String classifier, String version)
    finds a file associated with the GAV in the local installationDir.
    getInstance(Path installationDir)
    returns artifact cache located at installationDir/{code CACHE_FOLDER}
    void
    record(org.wildfly.channel.MavenArtifact artifact, Path pathToArtifact)
    records file in the cache descriptor.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • CACHE_FOLDER

      public static final Path CACHE_FOLDER
  • Method Details

    • getInstance

      public static ArtifactCache getInstance(Path installationDir) throws IOException
      returns artifact cache located at installationDir/{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 the GAV in the local installationDir. The file is only matched if it's GAV is recorded in cache descriptor and the file has not been modified since the cache was created.
      Parameters:
      groupId -
      artifactId -
      extension -
      classifier -
      version -
      Returns:
      empty Optional if the file has not been matched, otherwise the matching File
    • record

      public void record(org.wildfly.channel.MavenArtifact artifact, Path pathToArtifact) throws IOException
      records file in the cache descriptor. The recorded path is relative to installationDir
      Parameters:
      artifact - - artifact to be recorded
      pathToArtifact - - location in the installation where the artifact can be found
      Throws:
      IOException
    • cache

      public void cache(org.wildfly.channel.MavenArtifact artifact) throws IOException
      caches the artifact in CACHE_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, org.eclipse.aether.repository.LocalRepositoryManager localRepositoryManager) throws IOException
      detects and caches the manifests from manifestRecord in CACHE_FOLDER. The version and content of the manifest is resolved using resolvedArtifacts. NOTE: only manifests identified by maven coordinates are cached.
      Parameters:
      manifestRecord - - record containing all manifest used in installation.
      localRepositoryManager - - Maven manager for the local repository.
      Throws:
      IOException