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)
DefaultResourceLoader.ClassPathContextResource
CLASSPATH_URL_PREFIX
Constructor and Description |
---|
ClassRelativeResourceLoader(Class<?> clazz)
Create a new ClassRelativeResourceLoader for the given class.
|
Modifier and Type | Method and Description |
---|---|
protected Resource |
getResourceByPath(String path)
Return a Resource handle for the resource at the given path.
|
addProtocolResolver, getClassLoader, getProtocolResolvers, getResource, setClassLoader
public ClassRelativeResourceLoader(Class<?> clazz)
clazz
- the class to load resources throughprotected Resource getResourceByPath(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)