org.springframework.osgi.io
Class OsgiBundleResourcePatternResolver

java.lang.Object
  extended by org.springframework.core.io.support.PathMatchingResourcePatternResolver
      extended by org.springframework.osgi.io.OsgiBundleResourcePatternResolver
All Implemented Interfaces:
ResourceLoader, ResourcePatternResolver

public class OsgiBundleResourcePatternResolver
extends PathMatchingResourcePatternResolver

OSGi-aware subclass of PathMatchingResourcePatternResolver. Can find resources in the bundle jar, bundle space or class space. See OsgiBundleResource for more information.

Author:
Costin Leau
See Also:
Bundle, OsgiBundleResource

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
OsgiBundleResourcePatternResolver(Bundle bundle)
           
OsgiBundleResourcePatternResolver(ResourceLoader resourceLoader)
           
 
Method Summary
protected  Set doFindPathMatchingFileResources(Resource rootDirResource, String subPattern, int searchType)
          Based on the search type, use the approapriate method
protected  void doRetrieveMatchingBundleEntries(Bundle bundle, String fullPattern, String dir, Set result, int searchType)
          Seach each level inside the bundle for entries based on the search strategy chosen.
protected  Resource[] findPathMatchingResources(String locationPattern, int searchType)
          Override it to pass in the searchType parameter.
 Resource[] getResources(String locationPattern)
           
protected  String handleString(String path)
          Handle candidates returned as Strings.
protected  String handleURL(URL path)
          Handle candidates returned as URLs.
 
Methods inherited from class org.springframework.core.io.support.PathMatchingResourcePatternResolver
convertClassLoaderURL, determineRootDir, doFindMatchingFileSystemResources, doFindPathMatchingFileResources, doFindPathMatchingJarResources, doRetrieveMatchingFiles, findAllClassPathResources, findPathMatchingResources, getClassLoader, getPathMatcher, getResource, getResourceLoader, isJarResource, retrieveMatchingFiles, setPathMatcher
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OsgiBundleResourcePatternResolver

public OsgiBundleResourcePatternResolver(Bundle bundle)

OsgiBundleResourcePatternResolver

public OsgiBundleResourcePatternResolver(ResourceLoader resourceLoader)
Method Detail

getResources

public Resource[] getResources(String locationPattern)
                        throws IOException
Specified by:
getResources in interface ResourcePatternResolver
Overrides:
getResources in class PathMatchingResourcePatternResolver
Throws:
IOException

findPathMatchingResources

protected Resource[] findPathMatchingResources(String locationPattern,
                                               int searchType)
                                        throws IOException
Override it to pass in the searchType parameter.

Throws:
IOException

doFindPathMatchingFileResources

protected Set doFindPathMatchingFileResources(Resource rootDirResource,
                                              String subPattern,
                                              int searchType)
                                       throws IOException
Based on the search type, use the approapriate method

Throws:
IOException
See Also:
OsgiBundleResource.BUNDLE_URL_PREFIX, PathMatchingResourcePatternResolver.getResources(java.lang.String)

doRetrieveMatchingBundleEntries

protected void doRetrieveMatchingBundleEntries(Bundle bundle,
                                               String fullPattern,
                                               String dir,
                                               Set result,
                                               int searchType)
                                        throws IOException
Seach each level inside the bundle for entries based on the search strategy chosen.

Parameters:
bundle - the bundle to do the lookup
fullPattern - matching pattern
dir - directory inside the bundle
result - set of results (used to concatenate matching sub dirs)
searchType - the search strategy to use
Throws:
IOException

handleURL

protected String handleURL(URL path)
Handle candidates returned as URLs.

Parameters:
path -
Returns:

handleString

protected String handleString(String path)
Handle candidates returned as Strings.

Parameters:
path -
Returns:


Copyright © 2006-2007 Spring Framework. All Rights Reserved.