Top Description Fields Constructors Methods
io.smallrye.common.resource

public final Class JarFileResourceLoader

extends Object
implements ResourceLoader
Class Inheritance
All Implemented Interfaces
io.smallrye.common.resource.ResourceLoader, java.io.Closeable, java.lang.AutoCloseable
Imports
java.io.IOException, java.net.URL, java.nio.file.Files, .Path, java.util.jar.JarEntry, .JarFile, .Manifest

A resource loader which corresponds to a JAR file.

Field Summary

Modifier and TypeField and Description
private final URL
private final JarFile
private Path

Constructor Summary

AccessConstructor and Description
public
JarFileResourceLoader(final Path
the path of the JAR file (must not be null)
jarPath
)

Construct a new instance.

public
JarFileResourceLoader(final Resource
the resource of the JAR file (must not be null)
resource
)

Construct a new instance from a JAR file contained within a resource.

Method Summary

Modifier and TypeMethod and Description
public URL
baseUrl()

Overrides default io.smallrye.common.resource.ResourceLoader.baseUrl.

Returns the base URL for this loader.

public void
close()

Overrides default io.smallrye.common.resource.ResourceLoader.close.

Release any system resources or allocations associated with this resource loader.

public Resource
findResource(final String
the resource path (must not be null)
path
)

Implements io.smallrye.common.resource.ResourceLoader.findResource.

Find a resource from this loader.

public Manifest
manifest()

Overrides default io.smallrye.common.resource.ResourceLoader.manifest.

Get the manifest for this resource loader, if any.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

baseback to summary
private final URL base
jarFileback to summary
private final JarFile jarFile
tempFileback to summary
private Path tempFile

Constructor Detail

JarFileResourceLoaderback to summary
public JarFileResourceLoader(final Path jarPath) throws IOException

Construct a new instance.

Parameters
jarPath:Path

the path of the JAR file (must not be null)

Exceptions
IOException:
if opening the JAR file fails for some reason
JarFileResourceLoaderback to summary
public JarFileResourceLoader(final Resource resource) throws IOException

Construct a new instance from a JAR file contained within a resource.

Parameters
resource:Resource

the resource of the JAR file (must not be null)

Exceptions
IOException:
if opening the JAR file fails for some reason

Method Detail

baseUrlback to summary
public URL baseUrl()

Overrides default io.smallrye.common.resource.ResourceLoader.baseUrl.

Doc from io.smallrye.common.resource.ResourceLoader.baseUrl.

Returns the base URL for this loader.

Returns:URL

the base URL for this loader

closeback to summary
public void close()

Overrides default io.smallrye.common.resource.ResourceLoader.close.

Doc from io.smallrye.common.resource.ResourceLoader.close.

Release any system resources or allocations associated with this resource loader.

findResourceback to summary
public Resource findResource(final String path)

Implements io.smallrye.common.resource.ResourceLoader.findResource.

Doc from io.smallrye.common.resource.ResourceLoader.findResource.

Find a resource from this loader.

Parameters
path:String

the resource path (must not be null)

Returns:Resource

the loaded resource, or null if no resource is found at the given path

manifestback to summary
public Manifest manifest() throws IOException

Overrides default io.smallrye.common.resource.ResourceLoader.manifest.

Doc from io.smallrye.common.resource.ResourceLoader.manifest.

Get the manifest for this resource loader, if any. The default implementation constructs a new instance every time, so the caller should avoid repeated invocation of this method, caching as needed.

Returns:Manifest

the manifest, or null if no manifest was found

Exceptions
IOException:
if the manifest resource could not be loaded