Class FilesystemResourceLoader
- All Implemented Interfaces:
ResourceLoader
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 FilesystemResourceLoader
s to allow lookup of files in more than
one base directory.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFilesystemResourceLoader
(Path baseDirectory, ClassLoader delegate) Creates a resource loader that resolves resources against the given base directory.FilesystemResourceLoader
(Path baseDirectory, Module delegate) Creates a resource loader that resolves resources against the given base directory.FilesystemResourceLoader
(Path baseDirectory, ResourceLoader delegate) Creates a resource loader that resolves resources against the given base directory. -
Method Summary
Modifier and TypeMethodDescription<T> Class<? extends T>
Finds class of the name and expected type<T> T
newInstance
(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
Creates a resource loader that resolves resources against the given base directory. Files not found in file system and class lookups are delegated toClassLoader
.To use this constructor with the Java Module System, you must open all modules that contain resources to the
org.apache.lucene.core
module, otherwise resources can't be looked up. It is recommended to useFilesystemResourceLoader(Path, Module)
for such use cases as this would limit to certain modules. -
FilesystemResourceLoader
Creates a resource loader that resolves resources against the given base directory. Files not found in file system and class lookups are delegated toModuleResourceLoader
.To use this constructor, you must open the module to the
org.apache.lucene.core
module, otherwise resources can't be looked up. -
FilesystemResourceLoader
Creates a resource loader that resolves resources against the given base directory. Files not found in file system and class lookups are delegated to the given delegateResourceLoader
.
-
-
Method Details
-
openResource
Description copied from interface:ResourceLoader
Opens a named resource- Specified by:
openResource
in interfaceResourceLoader
- Throws:
IOException
-
newInstance
Description copied from interface:ResourceLoader
Creates an instance of the name and expected type- Specified by:
newInstance
in interfaceResourceLoader
-
findClass
Description copied from interface:ResourceLoader
Finds class of the name and expected type- Specified by:
findClass
in interfaceResourceLoader
-