public abstract class AbstractJackson2Encoder extends Jackson2CodecSupport implements HttpMessageEncoder<Object>
Flux elements are collected into a List before serialization for
performance reason.JSON_VIEW_HINT, logger| Modifier | Constructor and Description |
|---|---|
protected |
AbstractJackson2Encoder(ObjectMapper mapper,
org.springframework.util.MimeType... mimeTypes)
Constructor with a Jackson
ObjectMapper to use. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canEncode(org.springframework.core.ResolvableType elementType,
org.springframework.util.MimeType mimeType) |
protected ObjectWriter |
customizeWriter(ObjectWriter writer,
org.springframework.util.MimeType mimeType,
org.springframework.core.ResolvableType elementType,
Map<String,Object> hints) |
reactor.core.publisher.Flux<org.springframework.core.io.buffer.DataBuffer> |
encode(org.reactivestreams.Publisher<?> inputStream,
org.springframework.core.io.buffer.DataBufferFactory bufferFactory,
org.springframework.core.ResolvableType elementType,
org.springframework.util.MimeType mimeType,
Map<String,Object> hints) |
org.springframework.core.io.buffer.DataBuffer |
encodeValue(Object value,
org.springframework.core.io.buffer.DataBufferFactory bufferFactory,
org.springframework.core.ResolvableType valueType,
org.springframework.util.MimeType mimeType,
Map<String,Object> hints) |
protected <A extends Annotation> |
getAnnotation(org.springframework.core.MethodParameter parameter,
Class<A> annotType) |
List<org.springframework.util.MimeType> |
getEncodableMimeTypes() |
List<org.springframework.util.MimeType> |
getEncodableMimeTypes(org.springframework.core.ResolvableType elementType) |
Map<String,Object> |
getEncodeHints(org.springframework.core.ResolvableType actualType,
org.springframework.core.ResolvableType elementType,
MediaType mediaType,
ServerHttpRequest request,
ServerHttpResponse response)
Get decoding hints based on the server request or annotations on the
target controller method parameter.
|
protected JsonEncoding |
getJsonEncoding(org.springframework.util.MimeType mimeType)
Determine the JSON encoding to use for the given mime type.
|
List<MediaType> |
getStreamingMediaTypes()
Return "streaming" media types for which flushing should be performed
automatically vs at the end of the input stream.
|
protected byte[] |
getStreamingMediaTypeSeparator(org.springframework.util.MimeType mimeType)
Return the separator to use for the given mime type.
|
void |
setStreamingMediaTypes(List<MediaType> mediaTypes)
Configure "streaming" media types for which flushing should be performed
automatically vs at the end of the stream.
|
getHints, getJavaType, getMimeTypes, getMimeTypes, getObjectMapper, getObjectMapperRegistrations, getObjectMappersForType, getParameter, logWarningIfNecessary, registerObjectMappersForType, selectObjectMapper, setObjectMapper, supportsMimeTypeprotected AbstractJackson2Encoder(ObjectMapper mapper, org.springframework.util.MimeType... mimeTypes)
ObjectMapper to use.public void setStreamingMediaTypes(List<MediaType> mediaTypes)
public boolean canEncode(org.springframework.core.ResolvableType elementType,
@Nullable
org.springframework.util.MimeType mimeType)
canEncode in interface org.springframework.core.codec.Encoder<Object>public reactor.core.publisher.Flux<org.springframework.core.io.buffer.DataBuffer> encode(org.reactivestreams.Publisher<?> inputStream,
org.springframework.core.io.buffer.DataBufferFactory bufferFactory,
org.springframework.core.ResolvableType elementType,
@Nullable
org.springframework.util.MimeType mimeType,
@Nullable
Map<String,Object> hints)
encode in interface org.springframework.core.codec.Encoder<Object>public org.springframework.core.io.buffer.DataBuffer encodeValue(Object value, org.springframework.core.io.buffer.DataBufferFactory bufferFactory, org.springframework.core.ResolvableType valueType, @Nullable org.springframework.util.MimeType mimeType, @Nullable Map<String,Object> hints)
encodeValue in interface org.springframework.core.codec.Encoder<Object>protected ObjectWriter customizeWriter(ObjectWriter writer, @Nullable org.springframework.util.MimeType mimeType, org.springframework.core.ResolvableType elementType, @Nullable Map<String,Object> hints)
@Nullable
protected byte[] getStreamingMediaTypeSeparator(@Nullable
org.springframework.util.MimeType mimeType)
By default, this method returns new line "\n" if the given
mime type is one of the configured streaming mime types.
protected JsonEncoding getJsonEncoding(@Nullable org.springframework.util.MimeType mimeType)
mimeType - the mime type as requested by the callernull)public List<org.springframework.util.MimeType> getEncodableMimeTypes()
getEncodableMimeTypes in interface org.springframework.core.codec.Encoder<Object>public List<org.springframework.util.MimeType> getEncodableMimeTypes(org.springframework.core.ResolvableType elementType)
getEncodableMimeTypes in interface org.springframework.core.codec.Encoder<Object>public List<MediaType> getStreamingMediaTypes()
HttpMessageEncodergetStreamingMediaTypes in interface HttpMessageEncoder<Object>public Map<String,Object> getEncodeHints(@Nullable org.springframework.core.ResolvableType actualType, org.springframework.core.ResolvableType elementType, @Nullable MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response)
HttpMessageEncodergetEncodeHints in interface HttpMessageEncoder<Object>actualType - the actual source type to encode, possibly a reactive
wrapper and sourced from MethodParameter,
i.e. providing access to method annotations.elementType - the element type within Flux/Mono that we're
trying to encode.request - the current requestresponse - the current responseprotected <A extends Annotation> A getAnnotation(org.springframework.core.MethodParameter parameter, Class<A> annotType)
getAnnotation in class Jackson2CodecSupport