001/* 002 * Copyright 2002-2017 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; 020 021import javax.servlet.http.HttpServletRequest; 022 023import org.apache.commons.logging.Log; 024import org.apache.commons.logging.LogFactory; 025 026import org.springframework.core.io.Resource; 027import org.springframework.lang.Nullable; 028 029/** 030 * Base class for {@link org.springframework.web.servlet.resource.ResourceResolver} 031 * implementations. Provides consistent logging. 032 * 033 * @author Rossen Stoyanchev 034 * @since 4.1 035 */ 036public abstract class AbstractResourceResolver implements ResourceResolver { 037 038 protected final Log logger = LogFactory.getLog(getClass()); 039 040 041 @Override 042 @Nullable 043 public Resource resolveResource(@Nullable HttpServletRequest request, String requestPath, 044 List<? extends Resource> locations, ResourceResolverChain chain) { 045 046 return resolveResourceInternal(request, requestPath, locations, chain); 047 } 048 049 @Override 050 @Nullable 051 public String resolveUrlPath(String resourceUrlPath, List<? extends Resource> locations, 052 ResourceResolverChain chain) { 053 054 return resolveUrlPathInternal(resourceUrlPath, locations, chain); 055 } 056 057 058 @Nullable 059 protected abstract Resource resolveResourceInternal(@Nullable HttpServletRequest request, 060 String requestPath, List<? extends Resource> locations, ResourceResolverChain chain); 061 062 @Nullable 063 protected abstract String resolveUrlPathInternal(String resourceUrlPath, 064 List<? extends Resource> locations, ResourceResolverChain chain); 065 066}