Package org.apache.lucene.util
Class ClasspathResourceLoader
java.lang.Object
org.apache.lucene.util.ClasspathResourceLoader
- All Implemented Interfaces:
ResourceLoader
Simple
ResourceLoader that uses ClassLoader.getResourceAsStream(String) and
Class.forName(String,boolean,ClassLoader) to open resources and classes, respectively.
To use this class with the Java Module System, you must open all modules on classpath that
contain resources to the org.apache.lucene.core module, otherwise resources can't be
looked up. It is recommended to use ModuleResourceLoader for such use cases as this would
limit to certain modules.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionClasspathResourceLoader(Class<?> clazz) Creates an instance using the context classloader to load Resources and classes Resources are resolved relative to the given class, if path is not absolute.ClasspathResourceLoader(ClassLoader loader) Creates an instance using the given classloader to load Resources and classes. -
Method Summary
Modifier and TypeMethodDescription<T> Class<? extends T> Finds class of the name and expected typeopenResource(String resource) Opens a named resourceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.lucene.util.ResourceLoader
newInstance
-
Constructor Details
-
ClasspathResourceLoader
Creates an instance using the given classloader to load Resources and classes. Resource paths must be absolute. -
ClasspathResourceLoader
Creates an instance using the context classloader to load Resources and classes Resources are resolved relative to the given class, if path is not absolute.
-
-
Method Details
-
openResource
Description copied from interface:ResourceLoaderOpens a named resource- Specified by:
openResourcein interfaceResourceLoader- Throws:
IOException
-
findClass
Description copied from interface:ResourceLoaderFinds class of the name and expected type- Specified by:
findClassin interfaceResourceLoader
-