Top Description Inners Fields Constructors Methods
org.springframework.core.io

public Class ClassRelativeResourceLoader

extends DefaultResourceLoader
Class Inheritance
Imports
org.springframework.util.Assert, .StringUtils

ResourceLoader implementation that interprets plain resource paths as relative to a given java.lang.Class.
Author
Juergen Hoeller
Since
3.0
See Also
Class#getResource(String), ClassPathResource#ClassPathResource(String, Class)

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
ClassRelativeResourceLoader.ClassRelativeContextResource

ClassPathResource that explicitly expresses a context-relative path through implementing the ContextResource interface.

Field Summary

Modifier and TypeField and Description
private final Class<?>

Constructor Summary

AccessConstructor and Description
public
ClassRelativeResourceLoader(Class<?>
the class to load resources through
clazz
)

Create a new ClassRelativeResourceLoader for the given class.

Method Summary

Modifier and TypeMethod and Description
protected Resource
getResourceByPath(String
the path to the resource
path
)

Overrides org.springframework.core.io.DefaultResourceLoader.getResourceByPath.

Return a Resource handle for the resource at the given path.

Inherited from org.springframework.core.io.DefaultResourceLoader:
addProtocolResolverclearResourceCachesgetClassLoadergetProtocolResolversgetResourcegetResourceCachesetClassLoader

Field Detail

clazzback to summary
private final Class<?> clazz

Constructor Detail

ClassRelativeResourceLoaderback to summary
public ClassRelativeResourceLoader(Class<?> clazz)

Create a new ClassRelativeResourceLoader for the given class.

Parameters
clazz:Class<?>

the class to load resources through

Method Detail

getResourceByPathback to summary
protected Resource getResourceByPath(String path)

Overrides org.springframework.core.io.DefaultResourceLoader.getResourceByPath.

Doc from org.springframework.core.io.DefaultResourceLoader.getResourceByPath.

Return a Resource handle for the resource at the given path.

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.

Parameters
path:String

the path to the resource

Returns:Resource

the corresponding Resource handle

Annotations
@Override
org.springframework.core.io back to summary

private Class ClassRelativeResourceLoader.ClassRelativeContextResource

extends ClassPathResource
implements ContextResource
Class Inheritance
All Implemented Interfaces
org.springframework.core.io.ContextResource, org.springframework.core.io.Resource, org.springframework.core.io.InputStreamSource

ClassPathResource that explicitly expresses a context-relative path through implementing the ContextResource interface.

Field Summary

Modifier and TypeField and Description
private final Class<?>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Resource
createRelative(String
the relative path (relative to this resource)
relativePath
)

Overrides org.springframework.core.io.ClassPathResource.createRelative.

Implements org.springframework.core.io.Resource.createRelative.

Create a resource relative to this resource.

public String
getPathWithinContext()

Implements org.springframework.core.io.ContextResource.getPathWithinContext.

Return the path within the enclosing 'context'.

Inherited from org.springframework.core.io.ClassPathResource:
equalsexistsgetClassLoadergetDescriptiongetFilenamegetInputStreamgetPathgetURLhashCodeisReadableresolveURL

Field Detail

clazzback to summary
private final Class<?> clazz

Hides org.springframework.core.io.ClassPathResource.clazz.

Constructor Detail

ClassRelativeContextResourceback to summary
public ClassRelativeContextResource(String path, Class<?> clazz)

Method Detail

createRelativeback to summary
public Resource createRelative(String relativePath)

Overrides org.springframework.core.io.ClassPathResource.createRelative.

Implements org.springframework.core.io.Resource.createRelative.

Doc from org.springframework.core.io.Resource.createRelative.

Create a resource relative to this resource.

Parameters
relativePath:String

the relative path (relative to this resource)

Returns:Resource

the resource handle for the relative resource

Annotations
@Override
getPathWithinContextback to summary
public String getPathWithinContext()

Implements org.springframework.core.io.ContextResource.getPathWithinContext.

Doc from org.springframework.core.io.ContextResource.getPathWithinContext.

Return the path within the enclosing 'context'.

This is typically path relative to a context-specific root directory, e.g. a ServletContext root or a PortletContext root.

Annotations
@Override