|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.core.io.support.PathMatchingResourcePatternResolver
ResourcePatternResolver that applies Ant-style path matching, using Spring's PathMatcher class.
Locations can either be suitable for ResourceLoader.getResource
(URLs like "file:C:/context.xml", pseudo-URLs like "classpath:/context.xml",
relative file paths like "/WEB-INF/context.xml"), or Ant-style patterns
like "/WEB-INF/*-context.xml".
In the pattern case, the locations have to be resolvable to java.io.File, to allow for searching though the specified directory tree. In particular, this will neither work with WAR files that are not expanded nor with class path resources in a JAR file.
PathMatcher
,
ResourceLoader.getResource(java.lang.String)
Field Summary | |
protected org.apache.commons.logging.Log |
logger
|
Constructor Summary | |
PathMatchingResourcePatternResolver(ResourceLoader resourceLoader)
Create new PathMatchingResourcePatternResolver. |
Method Summary | |
protected java.lang.String |
determineRootDir(java.lang.String location)
Determine the root directory for the given location. |
protected void |
doRetrieveMatchingFiles(java.lang.String fullPattern,
java.io.File dir,
java.util.List result)
Recursively retrieve files that match the given pattern, adding them to the given result list. |
Resource[] |
getResources(java.lang.String locationPattern)
Resolve the given location pattern into Resource objects. |
protected java.util.List |
retrieveMatchingFiles(java.io.File rootDir,
java.lang.String pattern)
Retrieve files that match the given path pattern, checking the given directory and its subdirectories. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected final org.apache.commons.logging.Log logger
Constructor Detail |
public PathMatchingResourcePatternResolver(ResourceLoader resourceLoader)
resourceLoader
- ResourceLoader to load root directories
and actual resources withMethod Detail |
public Resource[] getResources(java.lang.String locationPattern) throws java.io.IOException
ResourcePatternResolver
getResources
in interface ResourcePatternResolver
locationPattern
- the location pattern to resolve
java.io.IOException
- in case of I/O errorsprotected java.lang.String determineRootDir(java.lang.String location)
Used for determining the starting point for file matching,
resolving the root directory location to a java.io.File and
passing it into retrieveMatchingFiles
, with the
remainder of the location as pattern.
Will return "/WEB-INF" for the pattern "/WEB-INF/*.xml", for example.
location
- the location to check
retrieveMatchingFiles(java.io.File, java.lang.String)
protected java.util.List retrieveMatchingFiles(java.io.File rootDir, java.lang.String pattern) throws java.io.IOException
rootDir
- the directory to start frompattern
- the pattern to match against,
relative to the root directory
java.io.IOException
- if directory contents could not be retrievedprotected void doRetrieveMatchingFiles(java.lang.String fullPattern, java.io.File dir, java.util.List result) throws java.io.IOException
fullPattern
- the pattern to match against,
with preprended root directory pathdir
- the current directoryresult
- the list of matching files to add to
java.io.IOException
- if directory contents could not be retrieved
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |