001/*
002 * Copyright 2002-2016 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.reactive.resource;
018
019import java.util.List;
020
021import org.apache.commons.logging.Log;
022import org.apache.commons.logging.LogFactory;
023import reactor.core.publisher.Mono;
024
025import org.springframework.core.io.Resource;
026import org.springframework.lang.Nullable;
027import org.springframework.web.server.ServerWebExchange;
028
029/**
030 * Base {@link ResourceResolver} providing consistent logging.
031 *
032 * @author Rossen Stoyanchev
033 * @since 5.0
034 */
035public abstract class AbstractResourceResolver implements ResourceResolver {
036
037        protected final Log logger = LogFactory.getLog(getClass());
038
039
040        @Override
041        public Mono<Resource> resolveResource(@Nullable ServerWebExchange exchange, String requestPath,
042                        List<? extends Resource> locations, ResourceResolverChain chain) {
043
044                return resolveResourceInternal(exchange, requestPath, locations, chain);
045        }
046
047        @Override
048        public Mono<String> resolveUrlPath(String resourceUrlPath, List<? extends Resource> locations,
049                        ResourceResolverChain chain) {
050
051                return resolveUrlPathInternal(resourceUrlPath, locations, chain);
052        }
053
054
055        protected abstract Mono<Resource> resolveResourceInternal(@Nullable ServerWebExchange exchange,
056                        String requestPath, List<? extends Resource> locations, ResourceResolverChain chain);
057
058        protected abstract Mono<String> resolveUrlPathInternal(String resourceUrlPath,
059                        List<? extends Resource> locations, ResourceResolverChain chain);
060
061}