ModuleResourceLoader (Lucene 10.5.1 core API)
Description: declaration: package: org.apache.lucene.util, class: ModuleResourceLoader

Package org.apache.lucene.util

# Class ModuleResourceLoader

java.lang.Object
org.apache.lucene.util.ModuleResourceLoader

All Implemented Interfaces:
  `ResourceLoader`

public final class ModuleResourceLoader extends Object implements ResourceLoader
Simple `ResourceLoader` that uses `Module.getResourceAsStream(String)` and `Class.forName(Module,String)` to open resources and classes, respectively. Resource paths must be absolute to module's root.

To use this class, you must open the module to the `org.apache.lucene.core` module, otherwise resources can't be looked up.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ModuleResourceLoader(Module module)`
  Creates an instance using the given Java Module to load resources and classes.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `<T> Class<? extends T>`
  `findClass(String cname, Class<T> expectedType)`
  Finds class of the name and expected type
  `InputStream`
  `openResource(String resource)`
  Opens a named resource

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface org.apache.lucene.util.ResourceLoader

  `newInstance`

- ## Constructor Details

  - ### ModuleResourceLoader

    public ModuleResourceLoader(Module module)
    Creates an instance using the given Java Module to load resources and classes.

- ## Method Details

  - ### openResource

    public InputStream openResource(String resource) throws IOException
    Description copied from interface: `ResourceLoader`
    Opens a named resource
    Specified by:
      `openResource` in interface `ResourceLoader`
    Throws:
      `IOException`

  - ### findClass

    public <T> Class<? extends T> findClass(String cname, Class<T> expectedType)
    Description copied from interface: `ResourceLoader`
    Finds class of the name and expected type
    Specified by:
      `findClass` in interface `ResourceLoader`