class ModelInitializer
extends java.lang.Object
RequestMappingHandlerAdapter
with
default model initialization through @ModelAttribute
methods.Modifier and Type | Field and Description |
---|---|
private ReactiveAdapterRegistry |
adapterRegistry |
private ControllerMethodResolver |
methodResolver |
Constructor and Description |
---|
ModelInitializer(ControllerMethodResolver methodResolver,
ReactiveAdapterRegistry adapterRegistry) |
Modifier and Type | Method and Description |
---|---|
private java.util.List<java.lang.String> |
findModelAttributes(HandlerMethod handlerMethod,
SessionAttributesHandler sessionAttributesHandler)
Find
@ModelAttribute arguments also listed as @SessionAttributes . |
private java.lang.String |
getAttributeName(MethodParameter param) |
static java.lang.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. |
private <any> |
handleResult(HandlerResult handlerResult,
BindingContext bindingContext) |
<any> |
initModel(HandlerMethod handlerMethod,
InitBinderBindingContext bindingContext,
ServerWebExchange exchange)
Initialize the
Model based on a
(type-level) @SessionAttributes annotation and
@ModelAttribute methods. |
private <any> |
invokeModelAttributeMethods(BindingContext bindingContext,
java.util.List<InvocableHandlerMethod> modelMethods,
ServerWebExchange exchange) |
private boolean |
isAsyncVoidType(ResolvableType type,
ReactiveAdapter adapter) |
private final ControllerMethodResolver methodResolver
private final ReactiveAdapterRegistry adapterRegistry
public ModelInitializer(ControllerMethodResolver methodResolver, ReactiveAdapterRegistry adapterRegistry)
public <any> initModel(HandlerMethod handlerMethod, InitBinderBindingContext bindingContext, ServerWebExchange exchange)
Model
based on a
(type-level) @SessionAttributes
annotation and
@ModelAttribute
methods.handlerMethod
- the target controller methodbindingContext
- the context containing the modelexchange
- the current exchangeMono
for when the model is populated.private <any> invokeModelAttributeMethods(BindingContext bindingContext, java.util.List<InvocableHandlerMethod> modelMethods, ServerWebExchange exchange)
private <any> handleResult(HandlerResult handlerResult, BindingContext bindingContext)
private boolean isAsyncVoidType(ResolvableType type, @Nullable ReactiveAdapter adapter)
private java.lang.String getAttributeName(MethodParameter param)
private java.util.List<java.lang.String> findModelAttributes(HandlerMethod handlerMethod, SessionAttributesHandler sessionAttributesHandler)
@ModelAttribute
arguments also listed as @SessionAttributes
.public static java.lang.String getNameForParameter(MethodParameter parameter)
@ModelAttribute
parameter annotation (if present) or falling
back on parameter type based conventions.parameter
- a descriptor for the method parameterConventions.getVariableNameForParameter(MethodParameter)