Class ArchiveFileArtifactResourceResolver

  • All Implemented Interfaces:
    ArtifactResourceResolver, Prioritized, java.lang.Comparable<Prioritized>

    public class ArchiveFileArtifactResourceResolver
    extends AbstractArtifactResourceResolver
    A concrete implementation of ArtifactResourceResolver that resolves artifacts based on archive files.

    ArchiveFileArtifactResourceResolver interprets the naming convention of archive files to extract artifact metadata such as artifactId and version. The resolver expects file names to follow a specific format: [artifactId]-[version].[extension], where only the artifactId is mandatory.

    Resolution Logic

    • If the given URL points to a directory or cannot be resolved to a valid archive file, resolution fails.
    • The filename is parsed using hyphen ('-') as the delimiter between artifact ID and version.
    • If no hyphen is found, only the artifact ID will be extracted, and the version will be set to null.

    Example Usages

    
     // Example 1: With both artifactId and version
     URL url = new File("my-artifact-1.0.0.jar").toURI().toURL();
     Artifact artifact = resolver.resolve(url);
     System.out.println(artifact.getArtifactId()); // Outputs: "my-artifact"
     System.out.println(artifact.getVersion());    // Outputs: "1.0.0"
    
     // Example 2: With only artifactId
     URL url = new File("my-artifact.jar").toURI().toURL();
     Artifact artifact = resolver.resolve(url);
     System.out.println(artifact.getArtifactId()); // Outputs: "my-artifact"
     System.out.println(artifact.getVersion());    // Outputs: null
     
    Since:
    1.0.0
    Author:
    Mercy
    See Also:
    AbstractArtifactResourceResolver, ArtifactResourceResolver
    • Constructor Detail

      • ArchiveFileArtifactResourceResolver

        public ArchiveFileArtifactResourceResolver()
      • ArchiveFileArtifactResourceResolver

        public ArchiveFileArtifactResourceResolver​(int priority)
      • ArchiveFileArtifactResourceResolver

        public ArchiveFileArtifactResourceResolver​(java.lang.ClassLoader classLoader,
                                                   int priority)
    • Method Detail

      • resolve

        public Artifact resolve​(java.net.URL resourceURL)
        Description copied from interface: ArtifactResourceResolver
        Resolve an instance Artifact from the resource of artifact.
        Parameters:
        resourceURL - the resource of artifact, it may the archive file or the directory
        Returns:
        an instance Artifact if found, otherwise null