View Javadoc
1   /*
2    * Copyright 2002-2014 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
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.web.servlet.resource;
18  
19  import java.util.List;
20  import javax.servlet.http.HttpServletRequest;
21  
22  import org.springframework.core.io.Resource;
23  
24  /**
25   * A contract for invoking a chain of {@link ResourceResolver}s where each resolver
26   * is given a reference to the chain allowing it to delegate when necessary.
27   *
28   * @author Jeremy Grelle
29   * @author Rossen Stoyanchev
30   * @author Sam Brannen
31   * @since 4.1
32   */
33  public interface ResourceResolverChain {
34  
35  	/**
36  	 * Resolve the supplied request and request path to a {@link Resource} that
37  	 * exists under one of the given resource locations.
38  	 *
39  	 * @param request the current request
40  	 * @param requestPath the portion of the request path to use
41  	 * @param locations the locations to search in when looking up resources
42  	 * @return the resolved resource or {@code null} if unresolved
43  	 */
44  	Resource resolveResource(HttpServletRequest request, String requestPath, List<? extends Resource> locations);
45  
46  	/**
47  	 * Resolve the externally facing <em>public</em> URL path for clients to use
48  	 * to access the resource that is located at the given <em>internal</em>
49  	 * resource path.
50  	 *
51  	 * <p>This is useful when rendering URL links to clients.
52  	 *
53  	 * @param resourcePath the internal resource path
54  	 * @param locations the locations to search in when looking up resources
55  	 * @return the resolved public URL path or {@code null} if unresolved
56  	 */
57  	String resolveUrlPath(String resourcePath, List<? extends Resource> locations);
58  
59  }