Class ArtifactManager
- java.lang.Object
-
- org.apache.sling.feature.io.artifacts.ArtifactManager
-
- All Implemented Interfaces:
AutoCloseable,ArtifactProvider
public class ArtifactManager extends Object implements AutoCloseable, ArtifactProvider
The artifact manager is the central service to get artifacts. It usesArtifactProviders to get artifacts. The providers are loaded using the service loader.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()ArtifactHandlergetArtifactHandler(String url)Get the full artifact url and file for an artifact.static ArtifactManagergetArtifactManager(ArtifactManagerConfig config)Get an artifact manager based on the configurationprotected StringgetFileContents(ArtifactHandler handler)static StringgetLatestSnapshot(String mavenMetadata)static StringgetValue(String xml, String[] xpath)URLprovide(ArtifactId id)Provide the artifact with the given id.voidshutdown()Shutdown the artifact manager.FeatureProvidertoFeatureProvider()Return a feature provider based on this artifact manager
-
-
-
Method Detail
-
getArtifactManager
public static ArtifactManager getArtifactManager(ArtifactManagerConfig config) throws IOException
Get an artifact manager based on the configuration- Parameters:
config- The configuration- Returns:
- The artifact manager
- Throws:
IOException- If the manager can't be initialized
-
shutdown
public void shutdown()
Shutdown the artifact manager.
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable
-
provide
public URL provide(ArtifactId id)
Description copied from interface:ArtifactProviderProvide the artifact with the given id.- Specified by:
providein interfaceArtifactProvider- Parameters:
id- The artifact id- Returns:
- The URL or
null
-
toFeatureProvider
public FeatureProvider toFeatureProvider()
Return a feature provider based on this artifact manager- Returns:
- A feature provider
- Since:
- 1.1.0
-
getArtifactHandler
public ArtifactHandler getArtifactHandler(String url) throws IOException
Get the full artifact url and file for an artifact.- Parameters:
url- Artifact url or relative path.- Returns:
- Absolute url and file in the form of a handler.
- Throws:
IOException- If something goes wrong or the artifact can't be found.
-
getFileContents
protected String getFileContents(ArtifactHandler handler) throws IOException
- Throws:
IOException
-
-