Package org.apache.sling.feature.io.artifacts

# 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 uses `ArtifactProvider`s to get artifacts. The providers are loaded using the service loader.

## Method Summary

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 configuration
`protected 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

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### 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 interface `AutoCloseable`

### provide

public URL provide(ArtifactId id)
Description copied from interface: `ArtifactProvider`
Provide the artifact with the given id.

Specified by:
  `provide` in interface `ArtifactProvider`
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`

### getValue

public static String getValue(String xml, String[] xpath)

### getLatestSnapshot

public static String getLatestSnapshot(String mavenMetadata)