java.lang.Object
io.smallrye.common.resource.JarFileResourceLoader
- All Implemented Interfaces:
ResourceLoader,Closeable,AutoCloseable
A resource loader which corresponds to a JAR file.
-
Field Summary
Fields inherited from interface io.smallrye.common.resource.ResourceLoader
EMPTY -
Constructor Summary
ConstructorsConstructorDescriptionJarFileResourceLoader(Resource resource) Construct a new instance from a JAR file contained within a resource.JarFileResourceLoader(Path jarPath) Construct a new instance. -
Method Summary
Modifier and TypeMethodDescriptionbaseUrl()Returns the base URL for this loader.voidclose()Release any system resources or allocations associated with this resource loader.findResource(String path) Find a resource from this loader.getChildLoader(String path) Get a child resource loader for the given child path.manifest()Get the manifest for this resource loader, if any.voidrelease()Hint that this resource loader is unlikely to be used in the near future.
-
Constructor Details
-
JarFileResourceLoader
Construct a new instance.- Parameters:
jarPath- the path of the JAR file (must not benull)- Throws:
IOException- if opening the JAR file fails for some reason
-
JarFileResourceLoader
Construct a new instance from a JAR file contained within a resource.- Parameters:
resource- the resource of the JAR file (must not benull)- Throws:
IOException- if opening the JAR file fails for some reason
-
-
Method Details
-
findResource
Description copied from interface:ResourceLoaderFind a resource from this loader.- Specified by:
findResourcein interfaceResourceLoader- Parameters:
path- the resource path (must not benull)- Returns:
- the loaded resource, or
nullif no resource is found at the given path - Throws:
IOException- if the resource could not be loaded
-
baseUrl
Description copied from interface:ResourceLoaderReturns the base URL for this loader.- Specified by:
baseUrlin interfaceResourceLoader- Returns:
- the base URL for this loader
-
getChildLoader
Description copied from interface:ResourceLoaderGet 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.- Specified by:
getChildLoaderin interfaceResourceLoader- Parameters:
path- the relative sub-path (must not benull)- Returns:
- the resource loader (not
null, may be empty)
-
manifest
Description copied from interface:ResourceLoaderGet 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.- Specified by:
manifestin interfaceResourceLoader- Returns:
- the manifest, or
nullif no manifest was found - Throws:
IOException- if the manifest resource could not be loaded
-
release
public void release()Description copied from interface:ResourceLoaderHint that this resource loader is unlikely to be used in the near future.- Specified by:
releasein interfaceResourceLoader
-
close
public void close()Description copied from interface:ResourceLoaderRelease any system resources or allocations associated with this resource loader.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceResourceLoader
-