Package io.microsphere.classloading
Class StreamArtifactResourceResolver
- java.lang.Object
-
- io.microsphere.classloading.AbstractArtifactResourceResolver
-
- io.microsphere.classloading.StreamArtifactResourceResolver
-
- All Implemented Interfaces:
ArtifactResourceResolver,Prioritized,java.lang.Comparable<Prioritized>
- Direct Known Subclasses:
ManifestArtifactResourceResolver,MavenArtifactResourceResolver
public abstract class StreamArtifactResourceResolver extends AbstractArtifactResourceResolver
An abstract base class for implementingArtifactResourceResolverthat provides a skeletal implementation to resolve artifact resources from either a streamable resource (like a URL) or an archive file (like a JAR). This class handles common concerns such as:- Stream Handling: Reads and processes artifact metadata from various sources including URLs, JAR files, and directories.
- Error Handling: Provides consistent error logging when reading or resolving artifacts fails.
- Archive Support: Offers utility methods to extract metadata from JARs or files within a directory structure.
- Extensibility: Declares abstract methods that subclasses must implement to define custom logic for identifying metadata locations and constructing artifact instances.
Key Abstract Methods
isArtifactMetadata(String): Determines if the given relative path represents an artifact metadata file.resolve(URL, InputStream, ClassLoader): Constructs an artifact from the provided metadata stream.
Example Usage
{@code public class CustomStreamArtifactResourceResolver extends StreamArtifactResourceResolver { public CustomStreamArtifactResourceResolver(ClassLoader classLoader, int priority) { super(classLoader, priority); }- Since:
- 1.0.0
- Author:
- Mercy
- See Also:
ArtifactResourceResolver,AbstractArtifactResourceResolver
-
-
Field Summary
-
Fields inherited from class io.microsphere.classloading.AbstractArtifactResourceResolver
classLoader, logger, priority
-
Fields inherited from interface io.microsphere.lang.Prioritized
COMPARATOR, MAX_PRIORITY, MIN_PRIORITY, NORMAL_PRIORITY
-
-
Constructor Summary
Constructors Constructor Description StreamArtifactResourceResolver(int priority)StreamArtifactResourceResolver(java.lang.ClassLoader classLoader, int priority)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected java.io.FilefindArtifactMetadata(java.io.File directory)protected java.util.jar.JarEntryfindArtifactMetadataEntry(java.util.jar.JarFile jarFile)protected abstract booleanisArtifactMetadata(java.lang.String relativePath)protected booleanisArtifactMetadataEntry(java.util.jar.JarEntry jarEntry)protected booleanisArtifactMetadataFile(java.io.File directory, java.io.File file)protected java.io.InputStreamreadArtifactMetadataDataFromArchiveFile(java.io.File archiveFile)protected java.io.InputStreamreadArtifactMetadataDataFromDirectory(java.io.File directory)protected java.io.InputStreamreadArtifactMetadataDataFromFile(java.io.File archiveFile)protected java.io.InputStreamreadArtifactMetadataDataFromResource(java.net.URL resourceURL, java.lang.ClassLoader classLoader)Artifactresolve(java.net.URL resourceURL)Resolve an instanceArtifactfromthe resourceof artifact.protected abstract Artifactresolve(java.net.URL resourceURL, java.io.InputStream artifactMetadataData, java.lang.ClassLoader classLoader)-
Methods inherited from class io.microsphere.classloading.AbstractArtifactResourceResolver
getPriority, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.microsphere.lang.Prioritized
compareTo
-
-
-
-
Method Detail
-
resolve
public final Artifact resolve(java.net.URL resourceURL)
Description copied from interface:ArtifactResourceResolverResolve an instanceArtifactfromthe resourceof artifact.- Parameters:
resourceURL-the resourceof artifact, it may the archive file or the directory- Returns:
- an instance
Artifactif found, otherwisenull
-
readArtifactMetadataDataFromResource
@Nullable protected java.io.InputStream readArtifactMetadataDataFromResource(java.net.URL resourceURL, java.lang.ClassLoader classLoader) throws java.io.IOException
- Throws:
java.io.IOException
-
readArtifactMetadataDataFromArchiveFile
@Nullable protected java.io.InputStream readArtifactMetadataDataFromArchiveFile(java.io.File archiveFile) throws java.io.IOException
- Throws:
java.io.IOException
-
readArtifactMetadataDataFromFile
@Nullable protected java.io.InputStream readArtifactMetadataDataFromFile(java.io.File archiveFile) throws java.io.IOException
- Throws:
java.io.IOException
-
readArtifactMetadataDataFromDirectory
@Nullable protected java.io.InputStream readArtifactMetadataDataFromDirectory(java.io.File directory) throws java.io.IOException
- Throws:
java.io.IOException
-
findArtifactMetadataEntry
protected java.util.jar.JarEntry findArtifactMetadataEntry(java.util.jar.JarFile jarFile) throws java.io.IOException- Throws:
java.io.IOException
-
findArtifactMetadata
protected java.io.File findArtifactMetadata(java.io.File directory) throws java.io.IOException- Throws:
java.io.IOException
-
isArtifactMetadataEntry
protected boolean isArtifactMetadataEntry(java.util.jar.JarEntry jarEntry)
-
isArtifactMetadataFile
protected boolean isArtifactMetadataFile(java.io.File directory, java.io.File file)
-
isArtifactMetadata
protected abstract boolean isArtifactMetadata(java.lang.String relativePath)
-
resolve
protected abstract Artifact resolve(java.net.URL resourceURL, java.io.InputStream artifactMetadataData, java.lang.ClassLoader classLoader) throws java.io.IOException
- Throws:
java.io.IOException
-
-