Package dev.getelements.elements.sdk
Interface ElementArtifactLoader
- All Known Implementing Classes:
CachingShrinkwrapElementArtifactLoader
public interface ElementArtifactLoader
An interface to load artifacts from coordinates. Artifacts are bundles of code, typically in jar form, that can
provide additional functionality. This service can load artifacts on-the-fly from various sources and load them into
the application.
Unless otherwise specified, the find family of methods will throw exceptions for any reason except a missing
artifact.
-
Method Summary
Modifier and TypeMethodDescriptionfindArtifact(Set<ArtifactRepository> repositories, String coordinates) Finds the artifact with the repositories and coordinates.default Optional<ClassLoader> findClassLoader(ClassLoader parent, Set<ArtifactRepository> repositories, String first, String... additional) Gets theClassLoaderloaded with the supplied coordinates.findClassLoader(ClassLoader parent, Set<ArtifactRepository> repositories, Set<String> coordinates) Opens aClassLoaderwith the supplied coordinates.findClasspathForArtifact(Set<ArtifactRepository> repositories, String coordinates) Finds the classpath for a particular artifact, including all transient dependencies.default ArtifactgetArtifact(Set<ArtifactRepository> repositories, String coordinates) Gets a single artifact.default ClassLoadergetClassLoader(ClassLoader parent, Set<ArtifactRepository> repositories, String first, String... additional) Gets theClassLoaderloaded with the supplied coordinates.default ClassLoadergetClassLoader(ClassLoader parent, Set<ArtifactRepository> repositories, Set<String> coordinates) Opens aClassLoaderwith the supplied coordinates.static ElementArtifactLoaderGets a new default instance of theElementArtifactLoader.
-
Method Details
-
getClassLoader
default ClassLoader getClassLoader(ClassLoader parent, Set<ArtifactRepository> repositories, String first, String... additional) Gets theClassLoaderloaded with the supplied coordinates.- Parameters:
parent- the parentClassLoader, may be null indicating that the system classpath is to be usedrepositories- the set of repositories to use for resolutionfirst- the first coordinatesadditional- the additional coordinates- Returns:
- the
ClassLoader
-
getClassLoader
default ClassLoader getClassLoader(ClassLoader parent, Set<ArtifactRepository> repositories, Set<String> coordinates) Opens aClassLoaderwith the supplied coordinates. This will resolve all requested coordinates and then return aClassLoaderwith the artifacts.- Parameters:
parent- the parentClassLoader, may be null indicating that the system classpath is to be usedrepositories- the set of repositories to use for resolutioncoordinates- the full set of coordinates- Returns:
- a
ClassLoaderfor the artifact registry - Throws:
SdkArtifactNotFoundException- if one or more of the requested artifacts can't be found
-
findClassLoader
default Optional<ClassLoader> findClassLoader(ClassLoader parent, Set<ArtifactRepository> repositories, String first, String... additional) Gets theClassLoaderloaded with the supplied coordinates.- Parameters:
parent- the parentClassLoader, may be null indicating that the system classpath is to be usedrepositories- the set of repositories to use for resolutionfirst- the first coordinatesadditional- the additional coordinates- Returns:
- the
ClassLoader
-
findClassLoader
Optional<ClassLoader> findClassLoader(ClassLoader parent, Set<ArtifactRepository> repositories, Set<String> coordinates) Opens aClassLoaderwith the supplied coordinates. This will resolve all requested coordinates and then return aClassLoaderwith the artifacts.- Returns:
- a
ClassLoaderfor the artifact registry
-
getArtifact
Gets a single artifact.- Parameters:
repositories- the repositories to searchcoordinates- the coordinates- Returns:
- the
Artifact - Throws:
SdkArtifactNotFoundException- if the artifact can't be found
-
findClasspathForArtifact
Finds the classpath for a particular artifact, including all transient dependencies.- Parameters:
repositories- the repositories to searchcoordinates- the coordinates- Returns:
- a stream of
Artifacts
-
findArtifact
Finds the artifact with the repositories and coordinates.- Parameters:
repositories- the repositories to searchcoordinates- the coordinates- Returns:
- an
Optionalwith the artifact
-
newDefaultInstance
Gets a new default instance of theElementArtifactLoader.- Returns:
- the
ElementArtifactLoader
-