Class AbstractJackson2Encoder
java.lang.Object
org.springframework.http.codec.json.Jackson2CodecSupport
org.springframework.http.codec.json.AbstractJackson2Encoder
- All Implemented Interfaces:
org.springframework.core.codec.Encoder<Object>, HttpMessageEncoder<Object>
- Direct Known Subclasses:
Jackson2CborEncoder, Jackson2JsonEncoder, Jackson2SmileEncoder
@Deprecated(since="7.0",
forRemoval=true)
public abstract class AbstractJackson2Encoder
extends Jackson2CodecSupport
implements HttpMessageEncoder<Object>
Deprecated, for removal: This API element is subject to removal in a future version.
Base class providing support methods for Jackson 2.x encoding. For non-streaming use
cases,
Flux elements are collected into a List before serialization for
performance reasons.- Since:
- 5.0
- Author:
- Sebastien Deleuze, Arjen Poutsma
-
Field Summary
Fields inherited from class Jackson2CodecSupport
JSON_VIEW_HINT, logger -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractJackson2Encoder(com.fasterxml.jackson.databind.ObjectMapper mapper, org.springframework.util.MimeType... mimeTypes) Deprecated, for removal: This API element is subject to removal in a future version.Constructor with a JacksonObjectMapperto use. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanEncode(org.springframework.core.ResolvableType elementType, @Nullable org.springframework.util.MimeType mimeType) Deprecated, for removal: This API element is subject to removal in a future version.protected com.fasterxml.jackson.databind.ObjectWritercustomizeWriter(com.fasterxml.jackson.databind.ObjectWriter writer, @Nullable org.springframework.util.MimeType mimeType, org.springframework.core.ResolvableType elementType, @Nullable Map<String, Object> hints) Deprecated, for removal: This API element is subject to removal in a future version.Subclasses can use this method to customize theObjectWriterused for writing values.reactor.core.publisher.Flux<org.springframework.core.io.buffer.DataBuffer> encode(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) Deprecated, for removal: This API element is subject to removal in a future version.org.springframework.core.io.buffer.DataBufferencodeValue(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) Deprecated, for removal: This API element is subject to removal in a future version.protected <A extends Annotation>
@Nullable AgetAnnotation(org.springframework.core.MethodParameter parameter, Class<A> annotType) Deprecated, for removal: This API element is subject to removal in a future version.List<org.springframework.util.MimeType> Deprecated, for removal: This API element is subject to removal in a future version.List<org.springframework.util.MimeType> getEncodableMimeTypes(org.springframework.core.ResolvableType elementType) Deprecated, for removal: This API element is subject to removal in a future version.getEncodeHints(@Nullable org.springframework.core.ResolvableType actualType, org.springframework.core.ResolvableType elementType, @Nullable MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response) Deprecated, for removal: This API element is subject to removal in a future version.Get decoding hints based on the server request or annotations on the target controller method parameter.protected com.fasterxml.jackson.core.JsonEncodinggetJsonEncoding(@Nullable org.springframework.util.MimeType mimeType) Deprecated, for removal: This API element is subject to removal in a future version.Determine the JSON encoding to use for the given mime type.Deprecated, for removal: This API element is subject to removal in a future version.Return "streaming" media types for which flushing should be performed automatically vs at the end of the input stream.protected byte @Nullable []getStreamingMediaTypeSeparator(@Nullable org.springframework.util.MimeType mimeType) Deprecated, for removal: This API element is subject to removal in a future version.Return the separator to use for the given mime type.voidsetStreamingMediaTypes(List<MediaType> mediaTypes) Deprecated, for removal: This API element is subject to removal in a future version.Configure "streaming" media types for which flushing should be performed automatically vs at the end of the stream.Methods inherited from class Jackson2CodecSupport
getHints, getJavaType, getMediaTypesForProblemDetail, getMimeTypes, getMimeTypes, getObjectMapper, getObjectMapperRegistrations, getObjectMappersForType, getParameter, logWarningIfNecessary, registerObjectMappersForType, selectObjectMapper, setObjectMapper, supportsMimeType
-
Constructor Details
-
AbstractJackson2Encoder
protected AbstractJackson2Encoder(com.fasterxml.jackson.databind.ObjectMapper mapper, org.springframework.util.MimeType... mimeTypes) Deprecated, for removal: This API element is subject to removal in a future version.Constructor with a JacksonObjectMapperto use.
-
-
Method Details
-
setStreamingMediaTypes
-
canEncode
public boolean canEncode(org.springframework.core.ResolvableType elementType, @Nullable org.springframework.util.MimeType mimeType) Deprecated, for removal: This API element is subject to removal in a future version.- Specified by:
canEncodein interfaceorg.springframework.core.codec.Encoder<Object>
-
encode
public reactor.core.publisher.Flux<org.springframework.core.io.buffer.DataBuffer> encode(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) Deprecated, for removal: This API element is subject to removal in a future version.- Specified by:
encodein interfaceorg.springframework.core.codec.Encoder<Object>
-
encodeValue
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) Deprecated, for removal: This API element is subject to removal in a future version.- Specified by:
encodeValuein interfaceorg.springframework.core.codec.Encoder<Object>
-
customizeWriter
protected com.fasterxml.jackson.databind.ObjectWriter customizeWriter(com.fasterxml.jackson.databind.ObjectWriter writer, @Nullable org.springframework.util.MimeType mimeType, org.springframework.core.ResolvableType elementType, @Nullable Map<String, Object> hints) Deprecated, for removal: This API element is subject to removal in a future version.Subclasses can use this method to customize theObjectWriterused for writing values.- Parameters:
writer- the writer instance to customizemimeType- the selected MIME typeelementType- the type of element values to writehints- a map with serialization hints; the Reactor Context, when available, may be accessed under the keyContextView.class.getName()- Returns:
- the customized
ObjectWriterto use
-
getStreamingMediaTypeSeparator
protected byte @Nullable [] getStreamingMediaTypeSeparator(@Nullable org.springframework.util.MimeType mimeType) Deprecated, for removal: This API element is subject to removal in a future version.Return the separator to use for the given mime type.By default, this method returns new line
"\n"if the given mime type is one of the configuredstreamingmime types.- Since:
- 5.3
-
getJsonEncoding
protected com.fasterxml.jackson.core.JsonEncoding getJsonEncoding(@Nullable org.springframework.util.MimeType mimeType) Deprecated, for removal: This API element is subject to removal in a future version.Determine the JSON encoding to use for the given mime type.- Parameters:
mimeType- the mime type as requested by the caller- Returns:
- the JSON encoding to use (never
null) - Since:
- 5.0.5
-
getEncodableMimeTypes
-
getEncodableMimeTypes
public List<org.springframework.util.MimeType> getEncodableMimeTypes(org.springframework.core.ResolvableType elementType) Deprecated, for removal: This API element is subject to removal in a future version.- Specified by:
getEncodableMimeTypesin interfaceorg.springframework.core.codec.Encoder<Object>
-
getStreamingMediaTypes
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:HttpMessageEncoderReturn "streaming" media types for which flushing should be performed automatically vs at the end of the input stream.- Specified by:
getStreamingMediaTypesin interfaceHttpMessageEncoder<Object>
-
getEncodeHints
public Map<String,Object> getEncodeHints(@Nullable org.springframework.core.ResolvableType actualType, org.springframework.core.ResolvableType elementType, @Nullable MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response) Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:HttpMessageEncoderGet decoding hints based on the server request or annotations on the target controller method parameter.- Specified by:
getEncodeHintsin interfaceHttpMessageEncoder<Object>- Parameters:
actualType- the actual source type to encode, possibly a reactive wrapper and sourced fromMethodParameter, i.e. providing access to method annotations.elementType- the element type withinFlux/Monothat we're trying to encode.request- the current requestresponse- the current response- Returns:
- a Map with hints, possibly empty
-
getAnnotation
protected <A extends Annotation> @Nullable A getAnnotation(org.springframework.core.MethodParameter parameter, Class<A> annotType) Deprecated, for removal: This API element is subject to removal in a future version.- Specified by:
getAnnotationin classJackson2CodecSupport
-
AbstractJacksonEncoder