Class AbstractNamedValueArgumentResolver
java.lang.Object
org.springframework.web.reactive.result.method.HandlerMethodArgumentResolverSupport
org.springframework.web.reactive.result.method.annotation.AbstractNamedValueArgumentResolver
- All Implemented Interfaces:
- HandlerMethodArgumentResolver
- Direct Known Subclasses:
- AbstractNamedValueSyncArgumentResolver, SessionAttributeMethodArgumentResolver
public abstract class AbstractNamedValueArgumentResolver
extends HandlerMethodArgumentResolverSupport
Abstract base class for resolving method arguments from a named value.
Request parameters, request headers, and path variables are examples of named
values. Each may have a name, a required flag, and a default value.
Subclasses define how to do the following:
- Obtain named value information for a method parameter
- Resolve names into argument values
- Handle missing argument values when argument values are required
- Optionally handle a resolved value
A default value string can contain ${...} placeholders and Spring Expression
Language #{...} expressions. For this to work a
ConfigurableBeanFactory must be supplied to the class constructor.
- Since:
- 5.0
- Author:
- Rossen Stoyanchev, Sebastien Deleuze
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected static classRepresents the information about a named value, including name, whether it's required and a default value.
- 
Field SummaryFields inherited from class HandlerMethodArgumentResolverSupportlogger
- 
Constructor SummaryConstructorsConstructorDescriptionAbstractNamedValueArgumentResolver(@Nullable ConfigurableBeanFactory factory, ReactiveAdapterRegistry registry) Create a newAbstractNamedValueArgumentResolverinstance.
- 
Method SummaryModifier and TypeMethodDescriptionprotected abstract AbstractNamedValueArgumentResolver.NamedValueInfocreateNamedValueInfo(MethodParameter parameter) Create theAbstractNamedValueArgumentResolver.NamedValueInfoobject for the given method parameter.protected voidhandleMissingValue(String name, MethodParameter parameter) Invoked when a named value is required, butresolveName(String, MethodParameter, ServerWebExchange)returnednulland there is no default value.protected voidhandleMissingValue(String name, MethodParameter parameter, ServerWebExchange exchange) Invoked when a named value is required, butresolveName(String, MethodParameter, ServerWebExchange)returnednulland there is no default value.protected voidhandleResolvedValue(@Nullable Object arg, String name, MethodParameter parameter, Model model, ServerWebExchange exchange) Invoked after a value is resolved.reactor.core.publisher.Mono<Object> resolveArgument(MethodParameter parameter, BindingContext bindingContext, ServerWebExchange exchange) Resolve the value for the method parameter.protected abstract reactor.core.publisher.Mono<Object> resolveName(String name, MethodParameter parameter, ServerWebExchange exchange) Resolve the given parameter type and value name into an argument value.Methods inherited from class HandlerMethodArgumentResolverSupportcheckAnnotatedParamNoReactiveWrapper, checkParameterType, checkParameterTypeNoReactiveWrapper, getAdapterRegistryMethods inherited from class Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface HandlerMethodArgumentResolversupportsParameter
- 
Constructor Details- 
AbstractNamedValueArgumentResolverpublic AbstractNamedValueArgumentResolver(@Nullable ConfigurableBeanFactory factory, ReactiveAdapterRegistry registry) Create a newAbstractNamedValueArgumentResolverinstance.- Parameters:
- factory- a bean factory to use for resolving- ${...}placeholder and- #{...}SpEL expressions in default values, or- nullif default values are not expected to contain expressions
- registry- for checking reactive type wrappers
 
 
- 
- 
Method Details- 
resolveArgumentpublic reactor.core.publisher.Mono<Object> resolveArgument(MethodParameter parameter, BindingContext bindingContext, ServerWebExchange exchange) Description copied from interface:HandlerMethodArgumentResolverResolve the value for the method parameter.- Parameters:
- parameter- the method parameter
- bindingContext- the binding context to use
- exchange- the current exchange
- Returns:
- Monofor the argument value, possibly empty
 
- 
createNamedValueInfoprotected abstract AbstractNamedValueArgumentResolver.NamedValueInfo createNamedValueInfo(MethodParameter parameter) Create theAbstractNamedValueArgumentResolver.NamedValueInfoobject for the given method parameter. Implementations typically retrieve the method annotation by means ofMethodParameter.getParameterAnnotation(Class).- Parameters:
- parameter- the method parameter
- Returns:
- the named value information
 
- 
resolveNameprotected abstract reactor.core.publisher.Mono<Object> resolveName(String name, MethodParameter parameter, ServerWebExchange exchange) Resolve the given parameter type and value name into an argument value.- Parameters:
- name- the name of the value being resolved
- parameter- the method parameter to resolve to an argument value (pre-nested in case of a- Optionaldeclaration)
- exchange- the current exchange
- Returns:
- the resolved argument (may be empty Mono)
 
- 
handleMissingValueprotected void handleMissingValue(String name, MethodParameter parameter, ServerWebExchange exchange) Invoked when a named value is required, butresolveName(String, MethodParameter, ServerWebExchange)returnednulland there is no default value. Subclasses typically throw an exception in this case.- Parameters:
- name- the name for the value
- parameter- the method parameter
- exchange- the current exchange
 
- 
handleMissingValueInvoked when a named value is required, butresolveName(String, MethodParameter, ServerWebExchange)returnednulland there is no default value. Subclasses typically throw an exception in this case.- Parameters:
- name- the name for the value
- parameter- the method parameter
 
- 
handleResolvedValueprotected void handleResolvedValue(@Nullable Object arg, String name, MethodParameter parameter, Model model, ServerWebExchange exchange) Invoked after a value is resolved.- Parameters:
- arg- the resolved argument value
- name- the argument name
- parameter- the argument parameter type
- model- the model
- exchange- the current exchange
 
 
-