public class ClassRelativeResourceLoader extends DefaultResourceLoader
ResourceLoader
implementation that interprets plain resource paths
as relative to a given java.lang.Class
.Class.getResource(String)
,
ClassPathResource.ClassPathResource(String, Class)
Modifier and Type | Class and Description |
---|---|
private static class |
ClassRelativeResourceLoader.ClassRelativeContextResource
ClassPathResource that explicitly expresses a context-relative path
through implementing the ContextResource interface.
|
DefaultResourceLoader.ClassPathContextResource
Modifier and Type | Field and Description |
---|---|
private java.lang.Class |
clazz |
CLASSPATH_URL_PREFIX
Constructor and Description |
---|
ClassRelativeResourceLoader(java.lang.Class clazz)
Create a new ClassRelativeResourceLoader for the given class.
|
Modifier and Type | Method and Description |
---|---|
protected Resource |
getResourceByPath(java.lang.String path)
Return a Resource handle for the resource at the given path.
|
getClassLoader, getResource, setClassLoader
public ClassRelativeResourceLoader(java.lang.Class clazz)
clazz
- the class to load resources throughprotected Resource getResourceByPath(java.lang.String path)
DefaultResourceLoader
The default implementation supports class path locations. This should be appropriate for standalone implementations but can be overridden, e.g. for implementations targeted at a Servlet container.
getResourceByPath
in class DefaultResourceLoader
path
- the path to the resourceClassPathResource
,
FileSystemXmlApplicationContext.getResourceByPath(java.lang.String)
,
AbstractRefreshableWebApplicationContext.getResourceByPath(java.lang.String)