001/* 002 * Copyright 2002-2014 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.method.support; 018 019import org.springframework.core.MethodParameter; 020import org.springframework.web.bind.WebDataBinder; 021import org.springframework.web.bind.support.WebDataBinderFactory; 022import org.springframework.web.context.request.NativeWebRequest; 023 024/** 025 * Strategy interface for resolving method parameters into argument values in 026 * the context of a given request. 027 * 028 * @author Arjen Poutsma 029 * @since 3.1 030 * @see HandlerMethodReturnValueHandler 031 */ 032public interface HandlerMethodArgumentResolver { 033 034 /** 035 * Whether the given {@linkplain MethodParameter method parameter} is 036 * supported by this resolver. 037 * @param parameter the method parameter to check 038 * @return {@code true} if this resolver supports the supplied parameter; 039 * {@code false} otherwise 040 */ 041 boolean supportsParameter(MethodParameter parameter); 042 043 /** 044 * Resolves a method parameter into an argument value from a given request. 045 * A {@link ModelAndViewContainer} provides access to the model for the 046 * request. A {@link WebDataBinderFactory} provides a way to create 047 * a {@link WebDataBinder} instance when needed for data binding and 048 * type conversion purposes. 049 * @param parameter the method parameter to resolve. This parameter must 050 * have previously been passed to {@link #supportsParameter} which must 051 * have returned {@code true}. 052 * @param mavContainer the ModelAndViewContainer for the current request 053 * @param webRequest the current request 054 * @param binderFactory a factory for creating {@link WebDataBinder} instances 055 * @return the resolved argument value, or {@code null} 056 * @throws Exception in case of errors with the preparation of argument values 057 */ 058 Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, 059 NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception; 060 061}