public final class ClasspathResourceLoader extends Object implements ResourceLoader
ResourceLoader
that uses ClassLoader.getResourceAsStream(String)
and Class.forName(String,boolean,ClassLoader)
to open resources and
classes, respectively.Constructor and Description |
---|
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
a
ClassLoader instead. |
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.
|
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 ClasspathResourceLoader()
ClassLoader
instead.public ClasspathResourceLoader(ClassLoader loader)
public ClasspathResourceLoader(Class<?> clazz)
public InputStream openResource(String resource) throws IOException
ResourceLoader
openResource
in interface ResourceLoader
IOException
public <T> Class<? extends T> findClass(String cname, Class<T> expectedType)
ResourceLoader
findClass
in interface ResourceLoader
public <T> T newInstance(String cname, Class<T> expectedType)
ResourceLoader
newInstance
in interface ResourceLoader
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.