Module io.avaje.jex
Package io.avaje.jex

Interface ClassResourceLoader


public interface ClassResourceLoader
Loading resources from the classpath or module path.

When not specified Avaje Jex provides a default implementation that looks to find resources using the class loader associated with the ClassResourceLoader.

As a fallback, ClassLoader.getSystemResourceAsStream(String) is used if the loader returns null.

  • Method Details

    • fromClass

      static ClassResourceLoader fromClass(Class<?> clazz)
      Create a ClassResourceLoader instance based on a given Class.
      Parameters:
      clazz - The class to use for resource loading.
      Returns:
      A new ClassResourceLoader instance.
    • loadResource

      URL loadResource(String resourcePath)
      Loads the specified resource and returns its URL.
      Parameters:
      resourcePath - The path to the resource.
      Returns:
      The URL of the resource.
    • loadResourceAsStream

      InputStream loadResourceAsStream(String resourcePath)
      Loads the specified resource and returns an input stream to read its contents.
      Parameters:
      resourcePath - The path to the resource.
      Returns:
      An InputStream to read the resource.