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.core.io; 018 019import org.springframework.lang.Nullable; 020 021/** 022 * A resolution strategy for protocol-specific resource handles. 023 * 024 * <p>Used as an SPI for {@link DefaultResourceLoader}, allowing for 025 * custom protocols to be handled without subclassing the loader 026 * implementation (or application context implementation). 027 * 028 * @author Juergen Hoeller 029 * @since 4.3 030 * @see DefaultResourceLoader#addProtocolResolver 031 */ 032@FunctionalInterface 033public interface ProtocolResolver { 034 035 /** 036 * Resolve the given location against the given resource loader 037 * if this implementation's protocol matches. 038 * @param location the user-specified resource location 039 * @param resourceLoader the associated resource loader 040 * @return a corresponding {@code Resource} handle if the given location 041 * matches this resolver's protocol, or {@code null} otherwise 042 */ 043 @Nullable 044 Resource resolve(String location, ResourceLoader resourceLoader); 045 046}