org.springframework.web.portlet.context
Class PortletContextResourcePatternResolver

java.lang.Object
  extended by org.springframework.core.io.support.PathMatchingResourcePatternResolver
      extended by org.springframework.web.portlet.context.PortletContextResourcePatternResolver
All Implemented Interfaces:
ResourceLoader, ResourcePatternResolver

public class PortletContextResourcePatternResolver
extends PathMatchingResourcePatternResolver

PortletContext-aware subclass of PathMatchingResourcePatternResolver, able to find matching resources below the web application root directory via Portlet API's PortletContext.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.support.ResourcePatternResolver
CLASSPATH_ALL_URL_PREFIX
 
Fields inherited from interface org.springframework.core.io.ResourceLoader
CLASSPATH_URL_PREFIX
 
Constructor Summary
PortletContextResourcePatternResolver(javax.portlet.PortletContext portletContext)
          Create a new PortletContextResourcePatternResolver.
PortletContextResourcePatternResolver(ResourceLoader resourceLoader)
          Create a new PortletContextResourcePatternResolver.
 
Method Summary
protected  Set doFindPathMatchingFileResources(Resource rootDirResource, String subPattern)
          Overridden version which checks for PortletContextResource and uses PortletContext.getResourcePaths to find matching resources below the web application root directory.
protected  void doRetrieveMatchingPortletContextResources(javax.portlet.PortletContext portletContext, String fullPattern, String dir, Set 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
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
 

Constructor Detail

PortletContextResourcePatternResolver

public PortletContextResourcePatternResolver(javax.portlet.PortletContext portletContext)
Create a new PortletContextResourcePatternResolver.

Parameters:
portletContext - the PortletContext to load resources with
See Also:
PortletContextResourceLoader.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 doFindPathMatchingFileResources(Resource rootDirResource,
                                              String subPattern)
                                       throws IOException
Overridden version which checks for PortletContextResource and uses PortletContext.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 Resource
subPattern - the sub pattern to match (below the root directory)
Returns:
the 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), PortletContextResource, PortletContext.getResourcePaths(java.lang.String)

doRetrieveMatchingPortletContextResources

protected void doRetrieveMatchingPortletContextResources(javax.portlet.PortletContext portletContext,
                                                         String fullPattern,
                                                         String dir,
                                                         Set result)
                                                  throws IOException
Recursively retrieve PortletContextResources that match the given pattern, adding them to the given result set.

Parameters:
portletContext - the PortletContext to work on
fullPattern - the pattern to match against, with preprended root directory path
dir - the current directory
result - 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)


Copyright © 2002-2008 The Spring Framework.