public abstract class AbstractMappingJacksonResponseBodyAdvice extends java.lang.Object implements ResponseBodyAdvice<java.lang.Object>
ResponseBodyAdvice
implementations
that customize the response before JSON serialization with
AbstractJackson2HttpMessageConverter
's concrete subclasses.Constructor and Description |
---|
AbstractMappingJacksonResponseBodyAdvice() |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
beforeBodyWrite(java.lang.Object body,
MethodParameter returnType,
MediaType contentType,
java.lang.Class<? extends HttpMessageConverter<?>> converterType,
ServerHttpRequest request,
ServerHttpResponse response)
Invoked after an
HttpMessageConverter is selected and just before
its write method is invoked. |
protected abstract void |
beforeBodyWriteInternal(MappingJacksonValue bodyContainer,
MediaType contentType,
MethodParameter returnType,
ServerHttpRequest request,
ServerHttpResponse response)
Invoked only if the converter type is
MappingJackson2HttpMessageConverter . |
protected MappingJacksonValue |
getOrCreateContainer(java.lang.Object body)
Wrap the body in a
MappingJacksonValue value container (for providing
additional serialization instructions) or simply cast it if already wrapped. |
boolean |
supports(MethodParameter returnType,
java.lang.Class<? extends HttpMessageConverter<?>> converterType)
Whether this component supports the given controller method return type
and the selected
HttpMessageConverter type. |
public AbstractMappingJacksonResponseBodyAdvice()
public boolean supports(MethodParameter returnType, java.lang.Class<? extends HttpMessageConverter<?>> converterType)
ResponseBodyAdvice
HttpMessageConverter
type.supports
in interface ResponseBodyAdvice<java.lang.Object>
returnType
- the return typeconverterType
- the selected converter typetrue
if ResponseBodyAdvice.beforeBodyWrite(T, org.springframework.core.MethodParameter, org.springframework.http.MediaType, java.lang.Class<? extends org.springframework.http.converter.HttpMessageConverter<?>>, org.springframework.http.server.ServerHttpRequest, org.springframework.http.server.ServerHttpResponse)
should be invoked;
false
otherwise@Nullable public final java.lang.Object beforeBodyWrite(@Nullable java.lang.Object body, MethodParameter returnType, MediaType contentType, java.lang.Class<? extends HttpMessageConverter<?>> converterType, ServerHttpRequest request, ServerHttpResponse response)
ResponseBodyAdvice
HttpMessageConverter
is selected and just before
its write method is invoked.beforeBodyWrite
in interface ResponseBodyAdvice<java.lang.Object>
body
- the body to be writtenreturnType
- the return type of the controller methodcontentType
- the content type selected through content negotiationconverterType
- the converter type selected to write to the responserequest
- the current requestresponse
- the current responseprotected MappingJacksonValue getOrCreateContainer(java.lang.Object body)
MappingJacksonValue
value container (for providing
additional serialization instructions) or simply cast it if already wrapped.protected abstract void beforeBodyWriteInternal(MappingJacksonValue bodyContainer, MediaType contentType, MethodParameter returnType, ServerHttpRequest request, ServerHttpResponse response)
MappingJackson2HttpMessageConverter
.