Top Description Fields Methods
org.springframework.core.io.support

public Interface ResourcePatternResolver

extends ResourceLoader
Known Direct Implementers
org.springframework.core.io.support.PathMatchingResourcePatternResolver
Imports
java.io.IOException, org.springframework.core.io.Resource, .ResourceLoader

Strategy interface for resolving a location pattern (for example, an Ant-style path pattern) into Resource objects.

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

PathMatchingResourcePatternResolver is a standalone implementation that is usable outside an ApplicationContext, also used by 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 module path and the class path. Note that the resource location may also contain placeholders — for example "/beans-*.xml". JAR files or different directories in the module path or class path can contain multiple files of the same name.

Authors
Juergen Hoeller, Sam Brannen
Since
1.0.2
See Also
org.springframework.core.io.Resource, org.springframework.core.io.ResourceLoader, org.springframework.context.ApplicationContext, org.springframework.context.ResourceLoaderAware

Field Summary

Modifier and TypeField and Description
public static final String
CLASSPATH_ALL_URL_PREFIX

Pseudo URL prefix for all matching resources from the class path: "classpath*:".

Inherited from org.springframework.core.io.ResourceLoader:
CLASSPATH_URL_PREFIX

Method Summary

Modifier and TypeMethod and Description
public Resource[]

Returns:

the corresponding Resource objects
getResources
(String
the location pattern to resolve
locationPattern
)

Resolve the given location pattern into Resource objects.

Inherited from org.springframework.core.io.ResourceLoader:
getClassLoadergetResource

Field Detail

CLASSPATH_ALL_URL_PREFIXback to summary
public 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 path — for example, to locate all "beans.xml" files in the root of all deployed JAR files you can use the location pattern "classpath*:/beans.xml".

As of Spring Framework 6.0, the semantics for the "classpath*:" prefix have been expanded to include the module path as well as the class path.

See Also
org.springframework.core.io.ResourceLoader#CLASSPATH_URL_PREFIX

Method Detail

getResourcesback to summary
public 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:String

the location pattern to resolve

Returns:Resource[]

the corresponding Resource objects

Exceptions
IOException:
in case of I/O errors