Top Description Constructors Methods
org.springframework.web.servlet.mvc.method.annotation

public abstract Class RequestBodyAdviceAdapter

extends Object
implements RequestBodyAdvice
Class Inheritance
All Implemented Interfaces
org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice
Known Direct Subclasses
org.springframework.web.servlet.mvc.method.annotation.JsonViewRequestBodyAdvice
Imports
java.io.IOException, java.lang.reflect.Type, org.springframework.core.MethodParameter, org.springframework.http.HttpInputMessage, org.springframework.http.converter.HttpMessageConverter, org.springframework.lang.Nullable

A convenient starting point for implementing RequestBodyAdvice with default method implementations.

Subclasses are required to implement supports to return true depending on when the advice applies.

Author
Rossen Stoyanchev
Since
4.2

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Object
afterBodyRead(Object
set to the converter Object before the first advice is called
body
,
HttpInputMessage
the request
inputMessage
,
MethodParameter
the target method parameter
parameter
,
Type
the target type, not necessarily the same as the method parameter type, e.g. for HttpEntity<String>.
targetType
,
Class<? extends HttpMessageConverter<?>>
the converter used to deserialize the body
converterType
)

Implements org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice.afterBodyRead.

The default implementation returns the body that was passed in.

public HttpInputMessage
beforeBodyRead(HttpInputMessage
the request
inputMessage
,
MethodParameter
the target method parameter
parameter
,
Type
the target type, not necessarily the same as the method parameter type, e.g. for HttpEntity<String>.
targetType
,
Class<? extends HttpMessageConverter<?>>
the converter used to deserialize the body
converterType
)

Implements org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice.beforeBodyRead.

The default implementation returns the InputMessage that was passed in.

public Object
handleEmptyBody(Object
usually set to null before the first advice is called
body
,
HttpInputMessage
the request
inputMessage
,
MethodParameter
the method parameter
parameter
,
Type
the target type, not necessarily the same as the method parameter type, e.g. for HttpEntity<String>.
targetType
,
Class<? extends HttpMessageConverter<?>>
the selected converter type
converterType
)

Implements org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice.handleEmptyBody.

The default implementation returns the body that was passed in.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

RequestBodyAdviceAdapterback to summary
public RequestBodyAdviceAdapter()

Method Detail

afterBodyReadback to summary
public Object afterBodyRead(Object body, HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType)

Implements org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice.afterBodyRead.

The default implementation returns the body that was passed in.

Parameters
body:Object

Doc from org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice.afterBodyRead.

set to the converter Object before the first advice is called

inputMessage:HttpInputMessage

Doc from org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice.afterBodyRead.

the request

parameter:MethodParameter

Doc from org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice.afterBodyRead.

the target method parameter

targetType:Type

Doc from org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice.afterBodyRead.

the target type, not necessarily the same as the method parameter type, e.g. for HttpEntity<String>.

converterType:Class<? extends HttpMessageConverter<?>>

Doc from org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice.afterBodyRead.

the converter used to deserialize the body

Returns:Object

Doc from org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice.afterBodyRead.

the same body or a new instance

Annotations
@Override
beforeBodyReadback to summary
public HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType) throws IOException

Implements org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice.beforeBodyRead.

The default implementation returns the InputMessage that was passed in.

Parameters
inputMessage:HttpInputMessage

Doc from org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice.beforeBodyRead.

the request

parameter:MethodParameter

Doc from org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice.beforeBodyRead.

the target method parameter

targetType:Type

Doc from org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice.beforeBodyRead.

the target type, not necessarily the same as the method parameter type, e.g. for HttpEntity<String>.

converterType:Class<? extends HttpMessageConverter<?>>

Doc from org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice.beforeBodyRead.

the converter used to deserialize the body

Returns:HttpInputMessage

Doc from org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice.beforeBodyRead.

the input request or a new instance (never null)

Annotations
@Override
handleEmptyBodyback to summary
public Object handleEmptyBody(Object body, HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType)

Implements org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice.handleEmptyBody.

The default implementation returns the body that was passed in.

Parameters
body:Object

Doc from org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice.handleEmptyBody.

usually set to null before the first advice is called

inputMessage:HttpInputMessage

Doc from org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice.handleEmptyBody.

the request

parameter:MethodParameter

Doc from org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice.handleEmptyBody.

the method parameter

targetType:Type

Doc from org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice.handleEmptyBody.

the target type, not necessarily the same as the method parameter type, e.g. for HttpEntity<String>.

converterType:Class<? extends HttpMessageConverter<?>>

Doc from org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice.handleEmptyBody.

the selected converter type

Returns:Object

Doc from org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice.handleEmptyBody.

the value to use, or null which may then raise an HttpMessageNotReadableException if the argument is required

Annotations
@Override
@Nullable