Skip to content

io microsphere classloading ArchiveFileArtifactResourceResolver

github-actions[bot] edited this page Mar 21, 2026 · 1 revision

ArchiveFileArtifactResourceResolver

Type: Class | Module: microsphere-java-core | Package: io.microsphere.classloading | Since: 1.0.0

Source: microsphere-java-core/src/main/java/io/microsphere/classloading/ArchiveFileArtifactResourceResolver.java

Overview

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
`

Declaration

public class ArchiveFileArtifactResourceResolver extends AbstractArtifactResourceResolver

Author: Mercy

Version Information

  • Introduced in: 1.0.0
  • Current Project Version: 0.1.10-SNAPSHOT

Version Compatibility

This component is tested and compatible with the following Java versions:

Java Version Status
Java 8 ✅ Compatible
Java 11 ✅ Compatible
Java 17 ✅ Compatible
Java 21 ✅ Compatible
Java 25 ✅ Compatible

Examples

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

Usage

Maven Dependency

Add the following dependency to your pom.xml:

<dependency>
    <groupId>io.github.microsphere-projects</groupId>
    <artifactId>microsphere-java-core</artifactId>
    <version>${microsphere-java.version}</version>
</dependency>

Tip: Use the BOM (microsphere-java-dependencies) for consistent version management. See the Getting Started guide.

Import

import io.microsphere.classloading.ArchiveFileArtifactResourceResolver;

API Reference

Public Methods

Method Description
resolve

See Also

  • AbstractArtifactResourceResolver
  • ArtifactResourceResolver

This documentation was auto-generated from the source code of microsphere-java.

Home

java-annotations

java-core

jdk-tools

lang-model

annotation-processor

java-test

Clone this wiki locally