Package org.apache.lucene.analysis.util
Class FilesystemResourceLoader
- java.lang.Object
-
- org.apache.lucene.analysis.util.FilesystemResourceLoader
-
- All Implemented Interfaces:
ResourceLoader
public final class FilesystemResourceLoader extends java.lang.Object implements ResourceLoader
SimpleResourceLoader
that opens resource files from the local file system, optionally resolving against a base directory.This loader wraps a delegate
ResourceLoader
that is used to resolve all files, the current base directory does not contain.newInstance(java.lang.String, java.lang.Class<T>)
is always resolved against the delegate, as aClassLoader
is needed.You can chain several
FilesystemResourceLoader
s to allow lookup of files in more than one base directory.
-
-
Constructor Summary
Constructors Constructor Description FilesystemResourceLoader()
Creates a resource loader that requires absolute filenames or relative to CWD to resolve resources.FilesystemResourceLoader(java.io.File baseDirectory)
Creates a resource loader that resolves resources against the given base directory (may benull
to refer to CWD).FilesystemResourceLoader(java.io.File baseDirectory, ResourceLoader delegate)
Creates a resource loader that resolves resources against the given base directory (may benull
to refer to CWD).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> java.lang.Class<? extends T>
findClass(java.lang.String cname, java.lang.Class<T> expectedType)
Finds class of the name and expected type<T> T
newInstance(java.lang.String cname, java.lang.Class<T> expectedType)
Creates an instance of the name and expected typejava.io.InputStream
openResource(java.lang.String resource)
Opens a named resource
-
-
-
Constructor Detail
-
FilesystemResourceLoader
public FilesystemResourceLoader()
Creates a resource loader that requires absolute filenames or relative to CWD to resolve resources. Files not found in file system and class lookups are delegated to context classloader.
-
FilesystemResourceLoader
public FilesystemResourceLoader(java.io.File baseDirectory)
Creates a resource loader that resolves resources against the given base directory (may benull
to refer to CWD). Files not found in file system and class lookups are delegated to context classloader.
-
FilesystemResourceLoader
public FilesystemResourceLoader(java.io.File baseDirectory, ResourceLoader delegate)
Creates a resource loader that resolves resources against the given base directory (may benull
to refer to CWD). Files not found in file system and class lookups are delegated to the given delegateResourceLoader
.
-
-
Method Detail
-
openResource
public java.io.InputStream openResource(java.lang.String resource) throws java.io.IOException
Description copied from interface:ResourceLoader
Opens a named resource- Specified by:
openResource
in interfaceResourceLoader
- Throws:
java.io.IOException
-
newInstance
public <T> T newInstance(java.lang.String cname, java.lang.Class<T> expectedType)
Description copied from interface:ResourceLoader
Creates an instance of the name and expected type- Specified by:
newInstance
in interfaceResourceLoader
-
findClass
public <T> java.lang.Class<? extends T> findClass(java.lang.String cname, java.lang.Class<T> expectedType)
Description copied from interface:ResourceLoader
Finds class of the name and expected type- Specified by:
findClass
in interfaceResourceLoader
-
-