Interface ResourcePatternResolver

All Superinterfaces:
ResourceLoader
All Known Implementing Classes:
PathMatchingResourcePatternResolver

public interface ResourcePatternResolver extends ResourceLoader
Strategy interface for resolving a location pattern (for example, an Ant-style path pattern) into {link Resource} objects.

This is an extension to the {link org.springframework.core.io.ResourceLoader} interface. A passed-in ResourceLoader (for example, an {link org.springframework.context.ApplicationContext} passed in via {link org.springframework.context.ResourceLoaderAware} when running in a context) can be checked whether it implements this extended interface too.

{link PathMatchingResourcePatternResolver} is a standalone implementation that is usable outside an ApplicationContext, also used by {link ResourceArrayPropertyEditor} for populating Resource array bean properties.

Can be used with any sort of location pattern — for example, "/WEB-INF/*-context.xml". However, input patterns have to match the strategy implementation. This interface just specifies the conversion method rather than a specific pattern format.

This interface also defines a "classpath*:" resource prefix for all matching resources from the class path. Note that the resource location may also contain placeholders — for example "/beans-*.xml". JAR files or different directories in the class path can contain multiple files of the same name.

Since:
1.0.2
Author:
Juergen Hoeller see org.springframework.core.io.Resource see org.springframework.core.io.ResourceLoader see org.springframework.context.ApplicationContext see org.springframework.context.ResourceLoaderAware
  • Field Details

    • CLASSPATH_ALL_URL_PREFIX

      static final String CLASSPATH_ALL_URL_PREFIX
      Pseudo URL prefix for all matching resources from the class path: "classpath*:"

      This differs from ResourceLoader's classpath URL prefix in that it retrieves all matching resources for a given name (e.g. "/beans.xml"), for example in the root of all deployed JAR files. see org.springframework.core.io.ResourceLoader#CLASSPATH_URL_PREFIX

      See Also:
  • Method Details

    • getResources

      Resource[] getResources(String locationPattern) throws IOException
      Resolve the given location pattern into Resource objects.

      Overlapping resource entries that point to the same physical resource should be avoided, as far as possible. The result should have set semantics.

      Parameters:
      locationPattern - the location pattern to resolve
      Returns:
      the corresponding Resource objects
      Throws:
      IOException - in case of I/O errors