Package org.apache.lucene.analysis.util
Class ClasspathResourceLoader
- java.lang.Object
-
- org.apache.lucene.analysis.util.ClasspathResourceLoader
-
- All Implemented Interfaces:
ResourceLoader
public final class ClasspathResourceLoader extends Object implements ResourceLoader
SimpleResourceLoaderthat usesClassLoader.getResourceAsStream(String)andClass.forName(String,boolean,ClassLoader)to open resources and classes, respectively.
-
-
Constructor Summary
Constructors Constructor Description ClasspathResourceLoader()Deprecated.You should not use this ctor, because it uses the thread's context class loader, which is bad programming style.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 type<T> TnewInstance(String cname, Class<T> expectedType)Creates an instance of the name and expected typeInputStreamopenResource(String resource)Opens a named resource
-
-
-
Constructor Detail
-
ClasspathResourceLoader
@Deprecated public ClasspathResourceLoader()
Deprecated.You should not use this ctor, because it uses the thread's context class loader, which is bad programming style. Please specify a reference class or aClassLoaderinstead.Creates an instance using the context classloader to load resources and classes. Resource paths must be absolute.
-
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:ResourceLoaderOpens a named resource- Specified by:
openResourcein interfaceResourceLoader- Throws:
IOException
-
findClass
public <T> Class<? extends T> findClass(String cname, Class<T> expectedType)
Description copied from interface:ResourceLoaderFinds class of the name and expected type- Specified by:
findClassin interfaceResourceLoader
-
newInstance
public <T> T newInstance(String cname, Class<T> expectedType)
Description copied from interface:ResourceLoaderCreates an instance of the name and expected type- Specified by:
newInstancein interfaceResourceLoader
-
-