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) throws IOException
      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
      Throws:
      IOException - if the resource could not be loaded
    • 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
    • getChildLoader

      public ResourceLoader getChildLoader(String path)
      Description copied from interface: ResourceLoader
      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.
      Specified by:
      getChildLoader in interface ResourceLoader
      Parameters:
      path - the relative sub-path (must not be null)
      Returns:
      the resource loader (not null, may be empty)
    • 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
    • release

      public void release()
      Description copied from interface: ResourceLoader
      Hint that this resource loader is unlikely to be used in the near future.
      Specified by:
      release in interface ResourceLoader
    • 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