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 usesArtifactProvider
s 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 void
close()
ArtifactHandler
getArtifactHandler(String url)
Get the full artifact url and file for an artifact.static ArtifactManager
getArtifactManager(ArtifactManagerConfig config)
Get an artifact manager based on the configurationprotected String
getFileContents(ArtifactHandler handler)
static String
getLatestSnapshot(String mavenMetadata)
static String
getValue(String xml, String[] xpath)
URL
provide(ArtifactId id)
Provide the artifact with the given id.void
shutdown()
Shutdown the artifact manager.FeatureProvider
toFeatureProvider()
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:
close
in interfaceAutoCloseable
-
provide
public URL provide(ArtifactId id)
Description copied from interface:ArtifactProvider
Provide the artifact with the given id.- Specified by:
provide
in 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
-
-