org.springframework.core.io
Class DefaultResourceLoader
java.lang.Object
org.springframework.core.io.DefaultResourceLoader
- All Implemented Interfaces:
- ResourceLoader
- Direct Known Subclasses:
- AbstractApplicationContext, ServletContextResourceLoader
- public class DefaultResourceLoader
- extends java.lang.Object
- implements ResourceLoader
Default implementation of the ResourceLoader interface.
Used by ResourceEditor, but also suitable for standalone usage.
Will return an UrlResource if the location value is a URL, and a
ClassPathResource if it is a non-URL path or a "classpath:" pseudo-URL.
- Since:
- 10.03.2004
- Author:
- Juergen Hoeller
- See Also:
ResourceLoader.CLASSPATH_URL_PREFIX
,
ResourceEditor
,
UrlResource
,
ClassPathResource
Method Summary |
Resource |
getResource(java.lang.String location)
Return a Resource handle for the specified resource.
|
protected Resource |
getResourceByPath(java.lang.String path)
Return a Resource handle for the resource at the given path.
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DefaultResourceLoader
public DefaultResourceLoader()
getResource
public Resource getResource(java.lang.String location)
- Description copied from interface:
ResourceLoader
- Return a Resource handle for the specified resource.
The handle should always be a reusable resource descriptor,
allowing for multiple getInputStream calls.
- Must support fully qualified URLs, e.g. "file:C:/test.dat".
- Must support classpath pseudo-URLs, e.g. "classpath:test.dat".
- Should support relative file paths, e.g. "WEB-INF/test.dat".
(This will be implementation-specific, typically provided by an
ApplicationContext implementation.)
Note that a Resource handle does not imply an existing resource;
you need to invoke Resource's "exists" to check for existence.
- Specified by:
getResource
in interface ResourceLoader
- Parameters:
location
- resource location
- Returns:
- Resource handle
- See Also:
ResourceLoader.CLASSPATH_URL_PREFIX
,
Resource.exists()
,
InputStreamSource.getInputStream()
getResourceByPath
protected Resource getResourceByPath(java.lang.String path)
- Return a Resource handle for the resource at the given path.
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
- path to the resource
- Returns:
- Resource handle
- See Also:
ClassPathResource
,
FileSystemXmlApplicationContext.getResourceByPath(java.lang.String)
,
XmlWebApplicationContext.getResourceByPath(java.lang.String)
Copyright (C) 2003-2004 The Spring Framework Project.