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

pack-priv Class ModelInitializer

extends Object
Class Inheritance
Imports
java.lang.reflect.Method, java.util.ArrayList, .Arrays, .List, .Map, .Optional, reactor.core.publisher.Mono, org.springframework.core.Conventions, .KotlinDetector, .MethodParameter, .ReactiveAdapter, .ReactiveAdapterRegistry, .ResolvableType, org.springframework.core.annotation.AnnotatedElementUtils, org.springframework.lang.Nullable, org.springframework.util.Assert, .StringUtils, org.springframework.web.bind.annotation.ModelAttribute, org.springframework.web.method.HandlerMethod, org.springframework.web.reactive.BindingContext, .HandlerResult, org.springframework.web.reactive.result.method.InvocableHandlerMethod, org.springframework.web.server.ServerWebExchange

Package-private class to assist RequestMappingHandlerAdapter with default model initialization through @ModelAttribute methods.
Authors
Rossen Stoyanchev, Sebastien Deleuze
Since
5.0

Field Summary

Modifier and TypeField and Description
private final ReactiveAdapterRegistry
private final ControllerMethodResolver

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private List<String>
findModelAttributes(HandlerMethod handlerMethod, SessionAttributesHandler sessionAttributesHandler)

Find @ModelAttribute arguments also listed as @SessionAttributes.

private String
public static String

Returns:

the derived name
getNameForParameter
(MethodParameter
a descriptor for the method parameter
parameter
)

Derive the model attribute name for the given method parameter based on a @ModelAttribute parameter annotation (if present) or falling back on parameter type based conventions.

private Mono<Void>
handleResult(HandlerResult handlerResult, BindingContext bindingContext)

public Mono<Void>

Returns:

a Mono for when the model is populated.
initModel
(HandlerMethod
the target controller method
handlerMethod
,
InitBinderBindingContext
the context containing the model
bindingContext
,
ServerWebExchange
the current exchange
exchange
)

Initialize the Model based on a (type-level) @SessionAttributes annotation and @ModelAttribute methods.

private Mono<Void>
private boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

adapterRegistryback to summary
private final ReactiveAdapterRegistry adapterRegistry
methodResolverback to summary
private final ControllerMethodResolver methodResolver

Constructor Detail

ModelInitializerback to summary
public ModelInitializer(ControllerMethodResolver methodResolver, ReactiveAdapterRegistry adapterRegistry)

Method Detail

findModelAttributesback to summary
private List<String> findModelAttributes(HandlerMethod handlerMethod, SessionAttributesHandler sessionAttributesHandler)

Find @ModelAttribute arguments also listed as @SessionAttributes.

getAttributeNameback to summary
private String getAttributeName(MethodParameter param)
getNameForParameterback to summary
public static String getNameForParameter(MethodParameter parameter)

Derive the model attribute name for the given method parameter based on a @ModelAttribute parameter annotation (if present) or falling back on parameter type based conventions.

Parameters
parameter:MethodParameter

a descriptor for the method parameter

Returns:String

the derived name

See Also
Conventions#getVariableNameForParameter(MethodParameter)
handleResultback to summary
private Mono<Void> handleResult(HandlerResult handlerResult, BindingContext bindingContext)
initModelback to summary
public Mono<Void> initModel(HandlerMethod handlerMethod, InitBinderBindingContext bindingContext, ServerWebExchange exchange)

Initialize the Model based on a (type-level) @SessionAttributes annotation and @ModelAttribute methods.

Parameters
handlerMethod:HandlerMethod

the target controller method

bindingContext:InitBinderBindingContext

the context containing the model

exchange:ServerWebExchange

the current exchange

Returns:Mono<Void>

a Mono for when the model is populated.

Annotations
@SuppressWarnings:Convert2MethodRef
invokeModelAttributeMethodsback to summary
private Mono<Void> invokeModelAttributeMethods(BindingContext bindingContext, List<InvocableHandlerMethod> modelMethods, ServerWebExchange exchange)
isAsyncVoidTypeback to summary
private boolean isAsyncVoidType(ResolvableType type, MethodParameter typeSource, ReactiveAdapter adapter)