org.springframework.web.context.support
Class ServletContextResourcePatternResolver
java.lang.Object
org.springframework.core.io.support.PathMatchingResourcePatternResolver
org.springframework.web.context.support.ServletContextResourcePatternResolver
- All Implemented Interfaces:
- ResourceLoader, ResourcePatternResolver
public class ServletContextResourcePatternResolver
- extends PathMatchingResourcePatternResolver
ServletContext-aware subclass of PathMatchingResourcePatternResolver
,
able to find matching resources below the web application root directory
via Servlet 2.3's ServletContext.getResourcePaths
.
Falls back to the superclass' file system checking for other resources.
- Since:
- 1.1.2
- Author:
- Juergen Hoeller
Field Summary |
private static Log |
logger
|
Method Summary |
protected java.util.Set<Resource> |
doFindPathMatchingFileResources(Resource rootDirResource,
java.lang.String subPattern)
Overridden version which checks for ServletContextResource
and uses ServletContext.getResourcePaths to find
matching resources below the web application root directory. |
private void |
doRetrieveMatchingJarEntries(java.lang.String jarFilePath,
java.lang.String entryPattern,
java.util.Set<Resource> result)
Method extracts entries from the given jar by pattern. |
protected void |
doRetrieveMatchingServletContextResources(ServletContext servletContext,
java.lang.String fullPattern,
java.lang.String dir,
java.util.Set<Resource> result)
Recursively retrieve ServletContextResources that match the given pattern,
adding them to the given result set. |
Methods inherited from class org.springframework.core.io.support.PathMatchingResourcePatternResolver |
convertClassLoaderURL, determineRootDir, doFindMatchingFileSystemResources, doFindPathMatchingJarResources, doRetrieveMatchingFiles, findAllClassPathResources, findPathMatchingResources, getClassLoader, getJarFile, getPathMatcher, getResource, getResourceLoader, getResources, isJarResource, resolveRootDirResource, retrieveMatchingFiles, setPathMatcher |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
logger
private static final Log logger
ServletContextResourcePatternResolver
public ServletContextResourcePatternResolver(ServletContext servletContext)
- Create a new ServletContextResourcePatternResolver.
- Parameters:
servletContext
- the ServletContext to load resources with- See Also:
ServletContextResourceLoader#ServletContextResourceLoader(javax.servlet.ServletContext)
doFindPathMatchingFileResources
protected java.util.Set<Resource> doFindPathMatchingFileResources(Resource rootDirResource,
java.lang.String subPattern)
throws java.io.IOException
- Overridden version which checks for ServletContextResource
and uses
ServletContext.getResourcePaths
to find
matching resources below the web application root directory.
In case of other resources, delegates to the superclass version.
- Overrides:
doFindPathMatchingFileResources
in class PathMatchingResourcePatternResolver
- Parameters:
rootDirResource
- the root directory as ResourcesubPattern
- the sub pattern to match (below the root directory)
- Returns:
- the Set of matching Resource instances
- Throws:
java.io.IOException
- in case of I/O errors- See Also:
doRetrieveMatchingServletContextResources(ServletContext, java.lang.String, java.lang.String, java.util.Set)
,
ServletContextResource
,
javax.servlet.ServletContext#getResourcePaths
doRetrieveMatchingServletContextResources
protected void doRetrieveMatchingServletContextResources(ServletContext servletContext,
java.lang.String fullPattern,
java.lang.String dir,
java.util.Set<Resource> result)
throws java.io.IOException
- Recursively retrieve ServletContextResources that match the given pattern,
adding them to the given result set.
- Parameters:
servletContext
- the ServletContext to work onfullPattern
- the pattern to match against,
with preprended root directory pathdir
- the current directoryresult
- the Set of matching Resources to add to
- Throws:
java.io.IOException
- if directory contents could not be retrieved- See Also:
ServletContextResource
,
javax.servlet.ServletContext#getResourcePaths
doRetrieveMatchingJarEntries
private void doRetrieveMatchingJarEntries(java.lang.String jarFilePath,
java.lang.String entryPattern,
java.util.Set<Resource> result)
- Method extracts entries from the given jar by pattern.
- Parameters:
jarFilePath
- the path to the jar fileentryPattern
- the pattern for jar entries to matchresult
- the Set of matching Resources to add to
- Throws:
java.io.IOException
- if jar contents could not be retrieved