Class JarFileResourceLoader

java.lang.Object
io.smallrye.common.resource.JarFileResourceLoader
All Implemented Interfaces:
ResourceLoader, Closeable, AutoCloseable

public final class JarFileResourceLoader extends Object implements ResourceLoader
A resource loader which corresponds to a JAR file.
  • Constructor Details

    • JarFileResourceLoader

      public JarFileResourceLoader(Path jarPath) throws IOException
      Construct a new instance.
      Parameters:
      jarPath - the path of the JAR file (must not be null)
      Throws:
      IOException - if opening the JAR file fails for some reason
    • JarFileResourceLoader

      public JarFileResourceLoader(Resource resource) throws IOException
      Construct a new instance from a JAR file contained within a resource.
      Parameters:
      resource - the resource of the JAR file (must not be null)
      Throws:
      IOException - if opening the JAR file fails for some reason
  • Method Details

    • findResource

      public Resource findResource(String path)
      Description copied from interface: ResourceLoader
      Find a resource from this loader.
      Specified by:
      findResource in interface ResourceLoader
      Parameters:
      path - the resource path (must not be null)
      Returns:
      the loaded resource, or null if no resource is found at the given path
    • baseUrl

      public URL baseUrl()
      Description copied from interface: ResourceLoader
      Returns the base URL for this loader.
      Specified by:
      baseUrl in interface ResourceLoader
      Returns:
      the base URL for this loader
    • manifest

      public Manifest manifest() throws IOException
      Description copied from interface: ResourceLoader
      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.
      Specified by:
      manifest in interface ResourceLoader
      Returns:
      the manifest, or null if no manifest was found
      Throws:
      IOException - if the manifest resource could not be loaded
    • close

      public void close()
      Description copied from interface: ResourceLoader
      Release any system resources or allocations associated with this resource loader.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface ResourceLoader