接口 PatternResourceLoader

所有超级接口:
ResourceLoader
所有已知实现类:
PathMatchingPatternResourceLoader

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

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

PathMatchingPatternResourceLoader is a standalone implementation that is usable outside an ApplicationContext.

Can be used with any sort of location pattern (e.g. "/WEB-INF/*-context.xml"): 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.

从以下版本开始:
4.0
作者:
Juergen Hoeller, Sam Brannen, TODAY 2021/10/7 17:26
另请参阅:
  • 字段详细资料

    • 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 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 4.0, the semantics for the "classpath*:" prefix have been expanded to include the module path as well as the class path.

      另请参阅:
  • 方法详细资料

    • getResources

      Set<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.

      参数:
      locationPattern - the location pattern to resolve
      返回:
      a mutable Set of the corresponding Resource instances
      抛出:
      IOException - in case of I/O errors
    • scan

      void scan(String locationPattern, ResourceConsumer consumer) throws IOException
      Scan 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.

      参数:
      locationPattern - the location pattern to resolve
      抛出:
      IOException - in case of I/O errors
    • getResourcesArray

      default Resource[] getResourcesArray(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.

      参数:
      locationPattern - the location pattern to resolve
      返回:
      the corresponding Resource objects
      抛出:
      IOException - in case of I/O errors
    • isUrl

      static boolean isUrl(@Nullable String resourceLocation)
      Return whether the given resource location is a URL: either a special "classpath" or "classpath*" pseudo URL or a standard URL.
      参数:
      resourceLocation - the location String to check
      返回:
      whether the location qualifies as a URL
      另请参阅:
    • fromResourceLoader

      static PatternResourceLoader fromResourceLoader(@Nullable ResourceLoader resourceLoader)
      Return a default PatternResourceLoader for the given ResourceLoader.

      This might be the ResourceLoader itself, if it implements the ResourcePatternResolver extension, or a default PathMatchingPatternResourceLoader built on the given ResourceLoader.

      参数:
      resourceLoader - the ResourceLoader to build a pattern resolver for (may be null to indicate a default ResourceLoader)
      返回:
      the ResourcePatternResolver
      另请参阅: