01: /*
02: * Copyright 2002-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.core.io.support;
18:
19: import java.io.IOException;
20:
21: import org.springframework.core.io.Resource;
22: import org.springframework.core.io.ResourceLoader;
23:
24: /**
25: * Strategy interface for resolving a location pattern (for example,
26: * an Ant-style path pattern) into Resource objects.
27: *
28: * <p>This is an extension to the {@link org.springframework.core.io.ResourceLoader}
29: * interface. A passed-in ResourceLoader (for example, an
30: * {@link org.springframework.context.ApplicationContext} passed in via
31: * {@link org.springframework.context.ResourceLoaderAware} when running in a context)
32: * can be checked whether it implements this extended interface too.
33: *
34: * <p>{@link PathMatchingResourcePatternResolver} is a standalone implementation
35: * that is usable outside an ApplicationContext, also used by
36: * {@link ResourceArrayPropertyEditor} for populating Resource array bean properties.
37: *
38: * <p>Can be used with any sort of location pattern (e.g. "/WEB-INF/*-context.xml"):
39: * Input patterns have to match the strategy implementation. This interface just
40: * specifies the conversion method rather than a specific pattern format.
41: *
42: * <p>This interface also suggests a new resource prefix "classpath*:" for all
43: * matching resources from the class path. Note that the resource location is
44: * expected to be a path without placeholders in this case (e.g. "/beans.xml");
45: * JAR files or classes directories can contain multiple files of the same name.
46: *
47: * @author Juergen Hoeller
48: * @since 1.0.2
49: * @see org.springframework.core.io.Resource
50: * @see org.springframework.core.io.ResourceLoader
51: * @see org.springframework.context.ApplicationContext
52: * @see org.springframework.context.ResourceLoaderAware
53: */
54: public interface ResourcePatternResolver extends ResourceLoader {
55:
56: /**
57: * Pseudo URL prefix for all matching resources from the class path: "classpath*:"
58: * This differs from ResourceLoader's classpath URL prefix in that it
59: * retrieves all matching resources for a given name (e.g. "/beans.xml"),
60: * for example in the root of all deployed JAR files.
61: * @see org.springframework.core.io.ResourceLoader#CLASSPATH_URL_PREFIX
62: */
63: String CLASSPATH_ALL_URL_PREFIX = "classpath*:";
64:
65: /**
66: * Resolve the given location pattern into Resource objects.
67: * <p>Overlapping resource entries that point to the same physical
68: * resource should be avoided, as far as possible. The result should
69: * have set semantics.
70: * @param locationPattern the location pattern to resolve
71: * @return the corresponding Resource objects
72: * @throws IOException in case of I/O errors
73: */
74: Resource[] getResources(String locationPattern) throws IOException;
75:
76: }
|