001/* 002 * Copyright 2002-2015 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.web.servlet.resource; 018 019import java.util.List; 020import javax.servlet.http.HttpServletRequest; 021 022import org.springframework.core.io.Resource; 023 024/** 025 * A contract for invoking a chain of {@link ResourceResolver}s where each resolver 026 * is given a reference to the chain allowing it to delegate when necessary. 027 * 028 * @author Jeremy Grelle 029 * @author Rossen Stoyanchev 030 * @author Sam Brannen 031 * @since 4.1 032 */ 033public interface ResourceResolverChain { 034 035 /** 036 * Resolve the supplied request and request path to a {@link Resource} that 037 * exists under one of the given resource locations. 038 * @param request the current request 039 * @param requestPath the portion of the request path to use 040 * @param locations the locations to search in when looking up resources 041 * @return the resolved resource or {@code null} if unresolved 042 */ 043 Resource resolveResource(HttpServletRequest request, String requestPath, List<? extends Resource> locations); 044 045 /** 046 * Resolve the externally facing <em>public</em> URL path for clients to use 047 * to access the resource that is located at the given <em>internal</em> 048 * resource path. 049 * <p>This is useful when rendering URL links to clients. 050 * @param resourcePath the internal resource path 051 * @param locations the locations to search in when looking up resources 052 * @return the resolved public URL path or {@code null} if unresolved 053 */ 054 String resolveUrlPath(String resourcePath, List<? extends Resource> locations); 055 056}