001/* 002 * Copyright 2002-2007 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.core.io.support; 018 019import java.io.IOException; 020 021import org.springframework.core.io.Resource; 022import org.springframework.core.io.ResourceLoader; 023 024/** 025 * Strategy interface for resolving a location pattern (for example, 026 * an Ant-style path pattern) into Resource objects. 027 * 028 * <p>This is an extension to the {@link org.springframework.core.io.ResourceLoader} 029 * interface. A passed-in ResourceLoader (for example, an 030 * {@link org.springframework.context.ApplicationContext} passed in via 031 * {@link org.springframework.context.ResourceLoaderAware} when running in a context) 032 * can be checked whether it implements this extended interface too. 033 * 034 * <p>{@link PathMatchingResourcePatternResolver} is a standalone implementation 035 * that is usable outside an ApplicationContext, also used by 036 * {@link ResourceArrayPropertyEditor} for populating Resource array bean properties. 037 * 038 * <p>Can be used with any sort of location pattern (e.g. "/WEB-INF/*-context.xml"): 039 * Input patterns have to match the strategy implementation. This interface just 040 * specifies the conversion method rather than a specific pattern format. 041 * 042 * <p>This interface also suggests a new resource prefix "classpath*:" for all 043 * matching resources from the class path. Note that the resource location is 044 * expected to be a path without placeholders in this case (e.g. "/beans.xml"); 045 * JAR files or classes directories can contain multiple files of the same name. 046 * 047 * @author Juergen Hoeller 048 * @since 1.0.2 049 * @see org.springframework.core.io.Resource 050 * @see org.springframework.core.io.ResourceLoader 051 * @see org.springframework.context.ApplicationContext 052 * @see org.springframework.context.ResourceLoaderAware 053 */ 054public interface ResourcePatternResolver extends ResourceLoader { 055 056 /** 057 * Pseudo URL prefix for all matching resources from the class path: "classpath*:" 058 * This differs from ResourceLoader's classpath URL prefix in that it 059 * retrieves all matching resources for a given name (e.g. "/beans.xml"), 060 * for example in the root of all deployed JAR files. 061 * @see org.springframework.core.io.ResourceLoader#CLASSPATH_URL_PREFIX 062 */ 063 String CLASSPATH_ALL_URL_PREFIX = "classpath*:"; 064 065 /** 066 * Resolve the given location pattern into Resource objects. 067 * <p>Overlapping resource entries that point to the same physical 068 * resource should be avoided, as far as possible. The result should 069 * have set semantics. 070 * @param locationPattern the location pattern to resolve 071 * @return the corresponding Resource objects 072 * @throws IOException in case of I/O errors 073 */ 074 Resource[] getResources(String locationPattern) throws IOException; 075 076}