Class PathResourceLoader

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

public final class PathResourceLoader extends Object implements ResourceLoader
A resource loader which loads resources from a base path.
  • Constructor Details

    • PathResourceLoader

      public PathResourceLoader(Path base)
      Construct a new instance. Note: to open a JAR file, use JarFileResourceLoader instead.
      Parameters:
      base - the base path (must not be null)
    • PathResourceLoader

      public PathResourceLoader(FileSystem fs)
      Construct a new instance from a filesystem's root. The filesystem is closed when this resource loader is closed. Note: to open a JAR file, use JarFileResourceLoader instead.
      Parameters:
      fs - the filesystem (must not be null)
  • 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
    • 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