|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.core.io.DefaultResourceLoader
public class DefaultResourceLoader
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.
ResourceLoader.CLASSPATH_URL_PREFIX
,
ResourceEditor
,
UrlResource
,
ClassPathResource
Field Summary |
---|
Fields inherited from interface org.springframework.core.io.ResourceLoader |
---|
CLASSPATH_URL_PREFIX |
Constructor Summary | |
---|---|
DefaultResourceLoader()
Create a new DefaultResourceLoader. |
|
DefaultResourceLoader(ClassLoader classLoader)
Create a new DefaultResourceLoader. |
Method Summary | |
---|---|
ClassLoader |
getClassLoader()
Return the ClassLoader to load class path resources with, or null if using the thread context class loader on actual access
(applying to the thread that constructs the ClassPathResource object). |
Resource |
getResource(String location)
Return a Resource handle for the specified resource. |
protected Resource |
getResourceByPath(String path)
Return a Resource handle for the resource at the given path. |
void |
setClassLoader(ClassLoader classLoader)
Specify the ClassLoader to load class path resources with, or null if using the thread context class loader. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DefaultResourceLoader()
ClassLoader access will happen via the thread context class loader on actual access (applying to the thread that does ClassPathResource calls).
Thread.getContextClassLoader()
public DefaultResourceLoader(ClassLoader classLoader)
classLoader
- the ClassLoader to load class path resources with,
or null
if using the thread context class loader on actual access
(applying to the thread that does ClassPathResource calls).Method Detail |
---|
public void setClassLoader(ClassLoader classLoader)
null
if using the thread context class loader.
The default is that ClassLoader access will happen via the thread context class loader.
public ClassLoader getClassLoader()
null
if using the thread context class loader on actual access
(applying to the thread that constructs the ClassPathResource object).
Will get passed to ClassPathResource's constructor for all ClassPathResource objects created by this resource loader.
ClassPathResource
public Resource getResource(String location)
ResourceLoader
getInputStream
calls.
Note that a Resource handle does not imply an existing resource; you need to invoke Resource's "exists" to check for existence.
getResource
in interface ResourceLoader
location
- the resource location
ResourceLoader.CLASSPATH_URL_PREFIX
,
Resource.exists()
,
InputStreamSource.getInputStream()
protected Resource getResourceByPath(String 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.
path
- path to the resource
ClassPathResource
,
FileSystemXmlApplicationContext.getResourceByPath(java.lang.String)
,
AbstractRefreshableWebApplicationContext.getResourceByPath(java.lang.String)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |