ResourceLoader interface.
Used by ResourceEditor, and serves as base class for
org..
Can also be used standalone.
Will return a UrlResource if the location value is a URL,
and a ClassPathResource if it is a non-URL path or a
"classpath:" pseudo-URL.
FileSystemResourceLoader, org.springframework.context.support.ClassPathXmlApplicationContext
| Modifier and Type | Class and Description |
|---|---|
| protected static class | DefaultResourceLoader.
ClassPathResource that explicitly expresses a context-relative path through implementing the ContextResource interface. |
| Modifier and Type | Field and Description |
|---|---|
| private ClassLoader | |
| private final Set | |
| private final Map |
| Access | Constructor and Description |
|---|---|
| public | |
| public | DefaultResourceLoader(ClassLoader
the ClassLoader to load class path resources with, or classLoader)null
for using the thread context class loader at the time of actual resource accessCreate a new DefaultResourceLoader. |
| Modifier and Type | Method and Description |
|---|---|
| public void | addProtocolResolver(ProtocolResolver resolver)
Register the given resolver with this resource loader, allowing for additional protocols to be handled. |
| public void | |
| public ClassLoader | getClassLoader()
Implements org. Return the ClassLoader to load class path resources with. |
| public Collection | getProtocolResolvers()
Return the collection of currently registered protocol resolvers, allowing for introspection as well as modification. |
| public Resource | getResource(String
the resource location location)Implements org. Return a |
| protected Resource | Returns: the corresponding Resource handlethe path to the resource path)Return a Resource handle for the resource at the given path. |
| public <T> Map | getResourceCache(Class<T>
the value type, e.g. an ASM valueType)MetadataReaderObtain a cache for the given value type, keyed by |
| public void | setClassLoader(ClassLoader classLoader)
Specify the ClassLoader to load class path resources with, or |
| classLoader | back to summary |
|---|---|
| private ClassLoader classLoader
| |
| protocolResolvers | back to summary |
|---|---|
| private final Set<ProtocolResolver> protocolResolvers | |
| resourceCaches | back to summary |
|---|---|
| private final Map<Class<?>, Map<Resource, ?>> resourceCaches | |
| DefaultResourceLoader | back to summary |
|---|---|
| public DefaultResourceLoader() Create a new DefaultResourceLoader. ClassLoader access will happen using the thread context class loader
at the time of actual resource access (since 5.3). For more control, pass
a specific ClassLoader to | |
| DefaultResourceLoader | back to summary |
|---|---|
| public DefaultResourceLoader(ClassLoader classLoader) Create a new DefaultResourceLoader.
| |
| addProtocolResolver | back to summary |
|---|---|
| public void addProtocolResolver(ProtocolResolver resolver) Register the given resolver with this resource loader, allowing for additional protocols to be handled. Any such resolver will be invoked ahead of this loader's standard resolution rules. It may therefore also override any default rules.
| |
| clearResourceCaches | back to summary |
|---|---|
| public void clearResourceCaches() Clear all resource caches in this resource loader.
| |
| getClassLoader | back to summary |
|---|---|
| public ClassLoader getClassLoader() Implements org. Return the ClassLoader to load class path resources with. Will get passed to ClassPathResource's constructor for all ClassPathResource objects created by this resource loader.
| |
| getProtocolResolvers | back to summary |
|---|---|
| public Collection Return the collection of currently registered protocol resolvers, allowing for introspection as well as modification.
| |
| getResource | back to summary |
|---|---|
| public Resource getResource(String location) Implements org. Doc from org. Return a The handle should always be a reusable resource descriptor,
allowing for multiple
Note that a | |
| getResourceByPath | back to summary |
|---|---|
| protected Resource getResourceByPath(String path) 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.
| |
| getResourceCache | back to summary |
|---|---|
| public <T> Map Obtain a cache for the given value type, keyed by
| |
| setClassLoader | back to summary |
|---|---|
| public void setClassLoader(ClassLoader classLoader) Specify the ClassLoader to load class path resources with, or The default is that ClassLoader access will happen using the thread context class loader at the time of actual resource access (since 5.3). | |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public Resource | createRelative(String
the relative path (relative to this resource) relativePath)Overrides org. Implements org. Create a resource relative to this resource. |
| public String | getPathWithinContext()
Implements org. Return the path within the enclosing 'context'. |
| ClassPathContextResource | back to summary |
|---|---|
| public ClassPathContextResource(String path, ClassLoader classLoader) | |
| createRelative | back to summary |
|---|---|
| public Resource createRelative(String relativePath) Overrides org. Implements org. Doc from org. Create a resource relative to this resource. | |
| getPathWithinContext | back to summary |
|---|---|
| public String getPathWithinContext() Implements org. Doc from org. 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.
| |