Top Description Fields Constructors Methods
org.springframework.web.method.annotation

public abstract Class AbstractWebArgumentResolverAdapter

extends Object
implements HandlerMethodArgumentResolver
Class Inheritance
All Implemented Interfaces
org.springframework.web.method.support.HandlerMethodArgumentResolver
Imports
org.apache.commons.logging.Log, .LogFactory, org.springframework.core.MethodParameter, org.springframework.lang.Nullable, org.springframework.util.Assert, .ClassUtils, org.springframework.web.bind.support.WebArgumentResolver, .WebDataBinderFactory, org.springframework.web.context.request.NativeWebRequest, org.springframework.web.method.support.HandlerMethodArgumentResolver, .ModelAndViewContainer

An abstract base class adapting a WebArgumentResolver to the HandlerMethodArgumentResolver contract.

Note

This class is provided for backwards compatibility. However it is recommended to re-write a WebArgumentResolver as HandlerMethodArgumentResolver. Since supportsParameter can only be implemented by actually resolving the value and then checking the result is not WebArgumentResolver#UNRESOLVED any exceptions raised must be absorbed and ignored since it's not clear whether the adapter doesn't support the parameter or whether it failed for an internal reason. The HandlerMethodArgumentResolver contract also provides access to model attributes and to WebDataBinderFactory (for type conversion).

Authors
Arjen Poutsma, Rossen Stoyanchev
Since
3.1

Field Summary

Modifier and TypeField and Description
private final WebArgumentResolver
private final Log

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected abstract NativeWebRequest
getWebRequest()

Required for access to NativeWebRequest in supportsParameter.

public Object
resolveArgument(MethodParameter
the method parameter to resolve. This parameter must have previously been passed to supportsParameter which must have returned true.
parameter
,
ModelAndViewContainer
the ModelAndViewContainer for the current request
mavContainer
,
NativeWebRequest
the current request
webRequest
,
WebDataBinderFactory
a factory for creating WebDataBinder instances
binderFactory
)

Implements org.springframework.web.method.support.HandlerMethodArgumentResolver.resolveArgument.

Delegate to the WebArgumentResolver instance.
public boolean
supportsParameter(MethodParameter
the method parameter to check
parameter
)

Implements org.springframework.web.method.support.HandlerMethodArgumentResolver.supportsParameter.

Actually resolve the value and check the resolved value is not WebArgumentResolver#UNRESOLVED absorbing _any_ exceptions.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

adapteeback to summary
private final WebArgumentResolver adaptee
loggerback to summary
private final Log logger

Constructor Detail

AbstractWebArgumentResolverAdapterback to summary
public AbstractWebArgumentResolverAdapter(WebArgumentResolver adaptee)

Create a new instance.

Method Detail

getWebRequestback to summary
protected abstract NativeWebRequest getWebRequest()

Required for access to NativeWebRequest in supportsParameter.

resolveArgumentback to summary
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception

Implements org.springframework.web.method.support.HandlerMethodArgumentResolver.resolveArgument.

Delegate to the WebArgumentResolver instance.

Parameters
parameter:MethodParameter

Doc from org.springframework.web.method.support.HandlerMethodArgumentResolver.resolveArgument.

the method parameter to resolve. This parameter must have previously been passed to supportsParameter which must have returned true.

mavContainer:ModelAndViewContainer

Doc from org.springframework.web.method.support.HandlerMethodArgumentResolver.resolveArgument.

the ModelAndViewContainer for the current request

webRequest:NativeWebRequest

Doc from org.springframework.web.method.support.HandlerMethodArgumentResolver.resolveArgument.

the current request

binderFactory:WebDataBinderFactory

Doc from org.springframework.web.method.support.HandlerMethodArgumentResolver.resolveArgument.

a factory for creating WebDataBinder instances

Returns:Object

Doc from org.springframework.web.method.support.HandlerMethodArgumentResolver.resolveArgument.

the resolved argument value, or null if not resolvable

Annotations
@Override
@Nullable
Exceptions
Exception:

Doc from org.springframework.web.method.support.HandlerMethodArgumentResolver.resolveArgument.

in case of errors with the preparation of argument values

IllegalStateException:
if the resolved value is not assignable to the method parameter.
supportsParameterback to summary
public boolean supportsParameter(MethodParameter parameter)

Implements org.springframework.web.method.support.HandlerMethodArgumentResolver.supportsParameter.

Actually resolve the value and check the resolved value is not WebArgumentResolver#UNRESOLVED absorbing _any_ exceptions.

Parameters
parameter:MethodParameter

Doc from org.springframework.web.method.support.HandlerMethodArgumentResolver.supportsParameter.

the method parameter to check

Returns:boolean

Doc from org.springframework.web.method.support.HandlerMethodArgumentResolver.supportsParameter.

true if this resolver supports the supplied parameter; false otherwise

Annotations
@Override