public final class FilesystemResourceLoader extends Object implements 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.
Constructor and Description |
---|
FilesystemResourceLoader(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.
Please specify a
ClassLoader instead. |
FilesystemResourceLoader(Path baseDirectory,
ClassLoader delegate)
Creates a resource loader that resolves resources against the given
base directory (may be
null to refer to CWD). |
FilesystemResourceLoader(Path baseDirectory,
ResourceLoader delegate)
Creates a resource loader that resolves resources against the given
base directory (may be
null to refer to CWD). |
Modifier and Type | Method and Description |
---|---|
<T> Class<? extends T> |
findClass(String cname,
Class<T> expectedType)
Finds class of the name and expected type
|
<T> T |
newInstance(String cname,
Class<T> expectedType)
Creates an instance of the name and expected type
|
InputStream |
openResource(String resource)
Opens a named resource
|
@Deprecated public FilesystemResourceLoader(Path baseDirectory)
ClassLoader
instead.null
to refer to CWD).
Files not found in file system and class lookups are delegated to context
classloader.public FilesystemResourceLoader(Path baseDirectory, ClassLoader delegate)
null
to refer to CWD).
Files not found in file system and class lookups are delegated to context
classloader.public FilesystemResourceLoader(Path baseDirectory, ResourceLoader delegate)
null
to refer to CWD).
Files not found in file system and class lookups are delegated
to the given delegate ResourceLoader
.public InputStream openResource(String resource) throws IOException
ResourceLoader
openResource
in interface ResourceLoader
IOException
public <T> T newInstance(String cname, Class<T> expectedType)
ResourceLoader
newInstance
in interface ResourceLoader
public <T> Class<? extends T> findClass(String cname, Class<T> expectedType)
ResourceLoader
findClass
in interface ResourceLoader
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.