Class PortletContextResourcePatternResolver
- java.lang.Object
- org.springframework.core.io.support.PathMatchingResourcePatternResolver
- org.springframework.web.portlet.context.PortletContextResourcePatternResolver
- All Implemented Interfaces:
ResourceLoader
,ResourcePatternResolver
public class PortletContextResourcePatternResolver extends PathMatchingResourcePatternResolver
PortletContext-aware subclass ofPathMatchingResourcePatternResolver
, able to find matching resources below the web application root directory via Portlet API'sPortletContext.getResourcePaths
. Falls back to the superclass' file system checking for other resources.The advantage of using
PortletContext.getResourcePaths
to find matching files is that it will work in a WAR file which has not been expanded too.- Since:
- 2.0
- Author:
- Juergen Hoeller, John A. Lewis
Field Summary
Fields inherited from interface org.springframework.core.io.ResourceLoader
CLASSPATH_URL_PREFIX
Fields inherited from interface org.springframework.core.io.support.ResourcePatternResolver
CLASSPATH_ALL_URL_PREFIX
Constructor Summary
Constructors Constructor Description PortletContextResourcePatternResolver(PortletContext portletContext)
Create a new PortletContextResourcePatternResolver.PortletContextResourcePatternResolver(ResourceLoader resourceLoader)
Create a new PortletContextResourcePatternResolver.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Set<Resource>
doFindPathMatchingFileResources(Resource rootDirResource, String subPattern)
Overridden version which checks for PortletContextResource and usesPortletContext.getResourcePaths
to find matching resources below the web application root directory.protected void
doRetrieveMatchingPortletContextResources(PortletContext portletContext, String fullPattern, String dir, Set<Resource> result)
Recursively retrieve PortletContextResources that match the given pattern, adding them to the given result set.Methods inherited from class org.springframework.core.io.support.PathMatchingResourcePatternResolver
addAllClassLoaderJarRoots, addClassPathManifestEntries, convertClassLoaderURL, determineRootDir, doFindAllClassPathResources, doFindMatchingFileSystemResources, doFindPathMatchingJarResources, doFindPathMatchingJarResources, doRetrieveMatchingFiles, findAllClassPathResources, findPathMatchingResources, getClassLoader, getJarFile, getPathMatcher, getResource, getResourceLoader, getResources, isJarResource, resolveRootDirResource, retrieveMatchingFiles, setPathMatcher
Constructor Detail
PortletContextResourcePatternResolver
public PortletContextResourcePatternResolver(PortletContext portletContext)
Create a new PortletContextResourcePatternResolver.- Parameters:
portletContext
- the PortletContext to load resources with- See Also:
PortletContextResourceLoader(javax.portlet.PortletContext)
PortletContextResourcePatternResolver
public PortletContextResourcePatternResolver(ResourceLoader resourceLoader)
Create a new PortletContextResourcePatternResolver.- Parameters:
resourceLoader
- the ResourceLoader to load root directories and actual resources with
Method Detail
doFindPathMatchingFileResources
protected Set<Resource> doFindPathMatchingFileResources(Resource rootDirResource, String subPattern) throws IOException
Overridden version which checks for PortletContextResource and usesPortletContext.getResourcePaths
to find matching resources below the web application root directory. In case of other resources, delegates to the superclass version.- Overrides:
doFindPathMatchingFileResources
in classPathMatchingResourcePatternResolver
- Parameters:
rootDirResource
- the root directory as ResourcesubPattern
- the sub pattern to match (below the root directory)- Returns:
- a mutable Set of matching Resource instances
- Throws:
IOException
- in case of I/O errors- See Also:
doRetrieveMatchingPortletContextResources(javax.portlet.PortletContext, java.lang.String, java.lang.String, java.util.Set<org.springframework.core.io.Resource>)
,PortletContextResource
,PortletContext.getResourcePaths(java.lang.String)
doRetrieveMatchingPortletContextResources
protected void doRetrieveMatchingPortletContextResources(PortletContext portletContext, String fullPattern, String dir, Set<Resource> result) throws IOException
Recursively retrieve PortletContextResources that match the given pattern, adding them to the given result set.- Parameters:
portletContext
- the PortletContext 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:
IOException
- if directory contents could not be retrieved- See Also:
PortletContextResource
,PortletContext.getResourcePaths(java.lang.String)