Class HandlerMethodArgumentResolverComposite
java.lang.Object
org.springframework.web.method.support.HandlerMethodArgumentResolverComposite
- All Implemented Interfaces:
HandlerMethodArgumentResolver
public class HandlerMethodArgumentResolverComposite
extends Object
implements HandlerMethodArgumentResolver
Resolves method parameters by delegating to a list of registered
HandlerMethodArgumentResolvers
.
Previously resolved method parameters are cached for faster lookups.- Since:
- 3.1
- Author:
- Rossen Stoyanchev, Juergen Hoeller
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddResolver
(HandlerMethodArgumentResolver resolver) Add the givenHandlerMethodArgumentResolver
.addResolvers
(List<? extends HandlerMethodArgumentResolver> resolvers) Add the givenHandlerMethodArgumentResolvers
.addResolvers
(HandlerMethodArgumentResolver... resolvers) Add the givenHandlerMethodArgumentResolvers
.void
clear()
Clear the list of configured resolvers and the resolver cache.getArgumentResolver
(MethodParameter parameter) Find a registeredHandlerMethodArgumentResolver
that supports the given method parameter.Return a read-only list with the contained resolvers, or an empty list.resolveArgument
(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) Iterate over registeredHandlerMethodArgumentResolvers
and invoke the one that supports it.boolean
supportsParameter
(MethodParameter parameter) Whether the given method parameter is supported by any registeredHandlerMethodArgumentResolver
.
-
Constructor Details
-
HandlerMethodArgumentResolverComposite
public HandlerMethodArgumentResolverComposite()
-
-
Method Details
-
addResolver
Add the givenHandlerMethodArgumentResolver
. -
addResolvers
public HandlerMethodArgumentResolverComposite addResolvers(@Nullable HandlerMethodArgumentResolver... resolvers) Add the givenHandlerMethodArgumentResolvers
.- Since:
- 4.3
-
addResolvers
public HandlerMethodArgumentResolverComposite addResolvers(@Nullable List<? extends HandlerMethodArgumentResolver> resolvers) Add the givenHandlerMethodArgumentResolvers
. -
getResolvers
Return a read-only list with the contained resolvers, or an empty list. -
clear
public void clear()Clear the list of configured resolvers and the resolver cache.- Since:
- 4.3
-
supportsParameter
Whether the given method parameter is supported by any registeredHandlerMethodArgumentResolver
.- Specified by:
supportsParameter
in interfaceHandlerMethodArgumentResolver
- Parameters:
parameter
- the method parameter to check- Returns:
true
if this resolver supports the supplied parameter;false
otherwise
-
resolveArgument
@Nullable public Object resolveArgument(MethodParameter parameter, @Nullable ModelAndViewContainer mavContainer, NativeWebRequest webRequest, @Nullable WebDataBinderFactory binderFactory) throws Exception Iterate over registeredHandlerMethodArgumentResolvers
and invoke the one that supports it.- Specified by:
resolveArgument
in interfaceHandlerMethodArgumentResolver
- Parameters:
parameter
- the method parameter to resolve. This parameter must have previously been passed toHandlerMethodArgumentResolver.supportsParameter(org.springframework.core.MethodParameter)
which must have returnedtrue
.mavContainer
- the ModelAndViewContainer for the current requestwebRequest
- the current requestbinderFactory
- a factory for creatingWebDataBinder
instances- Returns:
- the resolved argument value, or
null
if not resolvable - Throws:
IllegalArgumentException
- if no suitable argument resolver is foundException
- in case of errors with the preparation of argument values
-
getArgumentResolver
Find a registeredHandlerMethodArgumentResolver
that supports the given method parameter.
-