Package org.apache.lucene.analysis.util
Class FilesystemResourceLoader
java.lang.Object
org.apache.lucene.analysis.util.FilesystemResourceLoader
- All Implemented Interfaces:
ResourceLoader
Simple
ResourceLoader 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 a ClassLoader is needed.
You can chain several FilesystemResourceLoaders
to allow lookup of files in more than one base directory.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFilesystemResourceLoader(Path baseDirectory) Deprecated.You should not use this ctor, because it uses the thread's context class loader as fallback for resource lookups, which is bad programming style.FilesystemResourceLoader(Path baseDirectory, ClassLoader delegate) Creates a resource loader that resolves resources against the given base directory (may benullto refer to CWD).FilesystemResourceLoader(Path baseDirectory, ResourceLoader delegate) Creates a resource loader that resolves resources against the given base directory (may benullto refer to CWD). -
Method Summary
Modifier and TypeMethodDescription<T> Class<? extends T> Finds class of the name and expected type<T> TnewInstance(String cname, Class<T> expectedType) Creates an instance of the name and expected typeopenResource(String resource) Opens a named resource
-
Field Details
-
baseDirectory
-
delegate
-
-
Constructor Details
-
FilesystemResourceLoader
Deprecated.You should not use this ctor, because it uses the thread's context class loader as fallback for resource lookups, which is bad programming style. Please specify aClassLoaderinstead.Creates a resource loader that resolves resources against the given base directory (may benullto refer to CWD). Files not found in file system and class lookups are delegated to context classloader.- See Also:
-
FilesystemResourceLoader
Creates a resource loader that resolves resources against the given base directory (may benullto refer to CWD). Files not found in file system and class lookups are delegated to context classloader. -
FilesystemResourceLoader
Creates a resource loader that resolves resources against the given base directory (may benullto refer to CWD). Files not found in file system and class lookups are delegated to the given delegateResourceLoader.
-
-
Method Details
-
openResource
Description copied from interface:ResourceLoaderOpens a named resource- Specified by:
openResourcein interfaceResourceLoader- Throws:
IOException
-
newInstance
Description copied from interface:ResourceLoaderCreates an instance of the name and expected type- Specified by:
newInstancein interfaceResourceLoader
-
findClass
Description copied from interface:ResourceLoaderFinds class of the name and expected type- Specified by:
findClassin interfaceResourceLoader
-