Top Description Fields Methods
io.smallrye.common.resource

public Interface ResourceLoader

extends Closeable
Known Direct Implementers
io.smallrye.common.resource.URLResourceLoader, io.smallrye.common.resource.JarFileResourceLoader, io.smallrye.common.resource.PathResourceLoader
Imports
java.io.Closeable, .IOException, .InputStream, java.net.URL, java.util.jar.Manifest

A loader which can find resources by their path.

Field Summary

Modifier and TypeField and Description
public static final ResourceLoader
EMPTY

A resource loader containing no resources.

Method Summary

Modifier and TypeMethod and Description
public default URL

Returns:

the base URL for this loader
baseUrl
()

Returns the base URL for this loader.

public default void
close()

Implements java.io.Closeable.close.

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

public Resource

Returns:

the loaded resource, or null if no resource is found at the given path
findResource
(String
the resource path (must not be null)
path
)

Find a resource from this loader.

public default ResourceLoader

Returns:

the resource loader (not null, may be empty)
getChildLoader
(String
the relative sub-path (must not be null)
path
)

Get a child resource loader for the given child path.

public default Manifest

Returns:

the manifest, or null if no manifest was found
manifest
()

Get the manifest for this resource loader, if any.

public default void
release()

Hint that this resource loader is unlikely to be used in the near future.

Field Detail

EMPTYback to summary
public static final ResourceLoader EMPTY

A resource loader containing no resources.

Method Detail

baseUrlback to summary
public default URL baseUrl()

Returns the base URL for this loader.

Returns:URL

the base URL for this loader

closeback to summary
public default void close()

Implements java.io.Closeable.close.

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

findResourceback to summary
public Resource findResource(String path) throws IOException

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

Exceptions
IOException:
if the resource could not be loaded
getChildLoaderback to summary
public default ResourceLoader getChildLoader(String path)

Get a child resource loader for the given child path. This method always returns a resource loader, even if the path does not exist. Closing the child loader does not close the enclosing loader.

Parameters
path:String

the relative sub-path (must not be null)

Returns:ResourceLoader

the resource loader (not null, may be empty)

manifestback to summary
public default Manifest manifest() throws IOException

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
releaseback to summary
public default void release()

Hint that this resource loader is unlikely to be used in the near future.