Package org.apache.lucene.util
Class ClasspathResourceLoader
- java.lang.Object
-
- org.apache.lucene.util.ClasspathResourceLoader
-
- All Implemented Interfaces:
ResourceLoader
public final class ClasspathResourceLoader extends Object implements ResourceLoader
SimpleResourceLoader
that usesClassLoader.getResourceAsStream(String)
andClass.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 useModuleResourceLoader
for such use cases as this would limit to certain modules.- See Also:
ModuleResourceLoader
-
-
Constructor Summary
Constructors Constructor Description ClasspathResourceLoader(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Class<? extends T>
findClass(String cname, Class<T> expectedType)
Finds class of the name and expected typeInputStream
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 Detail
-
ClasspathResourceLoader
public ClasspathResourceLoader(ClassLoader loader)
Creates an instance using the given classloader to load Resources and classes. Resource paths must be absolute.
-
ClasspathResourceLoader
public ClasspathResourceLoader(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.
-
-
Method Detail
-
openResource
public InputStream openResource(String resource) throws IOException
Description copied from interface:ResourceLoader
Opens a named resource- Specified by:
openResource
in interfaceResourceLoader
- 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 interfaceResourceLoader
-
-