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 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
    • 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