Class GenericJackson2JsonRedisSerializer
java.lang.Object
org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer
- All Implemented Interfaces:
RedisSerializer<Object>
@Deprecated(since="4.0",
forRemoval=true)
public class GenericJackson2JsonRedisSerializer
extends Object
implements RedisSerializer<Object>
Deprecated, for removal: This API element is subject to removal in a future version.
Generic Jackson 2-based
RedisSerializer
that maps objects
to and from JSON using
dynamic typing.
JSON reading and writing can be customized by configuring a JacksonObjectReader
and
JacksonObjectWriter
.
- Since:
- 1.6
- Author:
- Christoph Strobl, Mark Paluch, Mao Shuai, John Blum, Anne Lee
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Deprecated, for removal: This API element is subject to removal in a future version.Builder for configuring and creating aGenericJackson2JsonRedisSerializer
. -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated, for removal: This API element is subject to removal in a future version.CreatesGenericJackson2JsonRedisSerializer
initialized with anObjectMapper
configured for default typing.GenericJackson2JsonRedisSerializer
(com.fasterxml.jackson.databind.ObjectMapper mapper) Deprecated, for removal: This API element is subject to removal in a future version.Setting a custom-configuredObjectMapper
is one way to take further control of the JSON serialization process.GenericJackson2JsonRedisSerializer
(com.fasterxml.jackson.databind.ObjectMapper mapper, JacksonObjectReader reader, JacksonObjectWriter writer) Deprecated, for removal: This API element is subject to removal in a future version.Setting a custom-configuredObjectMapper
is one way to take further control of the JSON serialization process.GenericJackson2JsonRedisSerializer
(@Nullable String typeHintPropertyName) Deprecated, for removal: This API element is subject to removal in a future version.CreatesGenericJackson2JsonRedisSerializer
initialized with anObjectMapper
configured for default typing using the givenname
.GenericJackson2JsonRedisSerializer
(@Nullable String typeHintPropertyName, JacksonObjectReader reader, JacksonObjectWriter writer) Deprecated, for removal: This API element is subject to removal in a future version.CreatesGenericJackson2JsonRedisSerializer
initialized with anObjectMapper
configured for default typing using the givenname
along with the given, requiredJacksonObjectReader
andJacksonObjectWriter
used to read/writeObjects
de/serialized as JSON. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()
Deprecated, for removal: This API element is subject to removal in a future version.Factory method returning a Builder used to construct and configure aGenericJackson2JsonRedisSerializer
.Deprecated, for removal: This API element is subject to removal in a future version.Builder method used to configure and customize the internal JacksonObjectMapper
created by thisGenericJackson2JsonRedisSerializer
and used to de/serializeobjects
as JSON.@Nullable Object
deserialize
(byte @Nullable [] source) Deprecated, for removal: This API element is subject to removal in a future version.Deserialize an object from the given binary data.<T> @Nullable T
deserialize
(byte @Nullable [] source, Class<T> type) Deprecated, for removal: This API element is subject to removal in a future version.protected com.fasterxml.jackson.databind.ObjectMapper
Deprecated, for removal: This API element is subject to removal in a future version.Gets the configuredObjectMapper
used internally by thisGenericJackson2JsonRedisSerializer
to de/serializeobjects
as JSON.static void
registerNullValueSerializer
(com.fasterxml.jackson.databind.ObjectMapper objectMapper, @Nullable String typeHintPropertyName) Deprecated, for removal: This API element is subject to removal in a future version.RegisterGenericJackson2JsonRedisSerializer.NullValueSerializer
in the givenObjectMapper
with an optionaltypeHintPropertyName
.protected com.fasterxml.jackson.databind.JavaType
resolveType
(byte[] source, Class<?> type) Deprecated, for removal: This API element is subject to removal in a future version.byte[]
Deprecated, for removal: This API element is subject to removal in a future version.Serialize the given object to binary data.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.data.redis.serializer.RedisSerializer
canSerialize, getTargetType
-
Constructor Details
-
GenericJackson2JsonRedisSerializer
public GenericJackson2JsonRedisSerializer()Deprecated, for removal: This API element is subject to removal in a future version.CreatesGenericJackson2JsonRedisSerializer
initialized with anObjectMapper
configured for default typing. -
GenericJackson2JsonRedisSerializer
Deprecated, for removal: This API element is subject to removal in a future version.CreatesGenericJackson2JsonRedisSerializer
initialized with anObjectMapper
configured for default typing using the givenname
.In case
name
is empty or null, thenJsonTypeInfo.Id.CLASS
will be used.- Parameters:
typeHintPropertyName
-name
of the JSON property holding type information; can be null.- See Also:
-
GenericJackson2JsonRedisSerializer
public GenericJackson2JsonRedisSerializer(@Nullable String typeHintPropertyName, JacksonObjectReader reader, JacksonObjectWriter writer) Deprecated, for removal: This API element is subject to removal in a future version.CreatesGenericJackson2JsonRedisSerializer
initialized with anObjectMapper
configured for default typing using the givenname
along with the given, requiredJacksonObjectReader
andJacksonObjectWriter
used to read/writeObjects
de/serialized as JSON.In case
name
is empty or null, thenJsonTypeInfo.Id.CLASS
will be used.- Parameters:
typeHintPropertyName
-name
of the JSON property holding type information; can be null.reader
-JacksonObjectReader
function to read objects usingObjectMapper
.writer
-JacksonObjectWriter
function to write objects usingObjectMapper
.- Since:
- 3.0
- See Also:
-
GenericJackson2JsonRedisSerializer
public GenericJackson2JsonRedisSerializer(com.fasterxml.jackson.databind.ObjectMapper mapper) Deprecated, for removal: This API element is subject to removal in a future version.Setting a custom-configuredObjectMapper
is one way to take further control of the JSON serialization process. For example, an extendedSerializerFactory
can be configured that provides custom serializers for specific types.- Parameters:
mapper
- must not be null.
-
GenericJackson2JsonRedisSerializer
public GenericJackson2JsonRedisSerializer(com.fasterxml.jackson.databind.ObjectMapper mapper, JacksonObjectReader reader, JacksonObjectWriter writer) Deprecated, for removal: This API element is subject to removal in a future version.Setting a custom-configuredObjectMapper
is one way to take further control of the JSON serialization process. For example, an extendedSerializerFactory
can be configured that provides custom serializers for specific types.- Parameters:
mapper
- must not be null.reader
- theJacksonObjectReader
function to read objects usingObjectMapper
.writer
- theJacksonObjectWriter
function to write objects usingObjectMapper
.- Since:
- 3.0
-
-
Method Details
-
builder
public static GenericJackson2JsonRedisSerializer.GenericJackson2JsonRedisSerializerBuilder builder()Deprecated, for removal: This API element is subject to removal in a future version.Factory method returning a Builder used to construct and configure aGenericJackson2JsonRedisSerializer
.- Returns:
- new
GenericJackson2JsonRedisSerializer.GenericJackson2JsonRedisSerializerBuilder
. - Since:
- 3.3.1
-
registerNullValueSerializer
public static void registerNullValueSerializer(com.fasterxml.jackson.databind.ObjectMapper objectMapper, @Nullable String typeHintPropertyName) Deprecated, for removal: This API element is subject to removal in a future version.RegisterGenericJackson2JsonRedisSerializer.NullValueSerializer
in the givenObjectMapper
with an optionaltypeHintPropertyName
. This method should be called by code that customizesGenericJackson2JsonRedisSerializer
by providing an externalObjectMapper
.- Parameters:
objectMapper
- the object mapper to customize.typeHintPropertyName
- name of the type property. Defaults to@class
if null/empty.- Since:
- 2.2
-
getObjectMapper
protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()Deprecated, for removal: This API element is subject to removal in a future version.Gets the configuredObjectMapper
used internally by thisGenericJackson2JsonRedisSerializer
to de/serializeobjects
as JSON.- Returns:
- the configured
ObjectMapper
.
-
serialize
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:RedisSerializer
Serialize the given object to binary data.- Specified by:
serialize
in interfaceRedisSerializer<Object>
- Parameters:
value
- object to serialize. Can be null.- Returns:
- the equivalent binary data. Can be an empty array but never null.
- Throws:
SerializationException
-
deserialize
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:RedisSerializer
Deserialize an object from the given binary data.- Specified by:
deserialize
in interfaceRedisSerializer<Object>
- Parameters:
source
- object binary representation. Can be null.- Returns:
- the equivalent object instance. Can be null.
- Throws:
SerializationException
-
deserialize
public <T> @Nullable T deserialize(byte @Nullable [] source, Class<T> type) throws SerializationException Deprecated, for removal: This API element is subject to removal in a future version.- Parameters:
source
- array of bytes containing the JSON to deserialize; can be null.type
-type
ofObject
from which the JSON will be deserialized; must not be null.- Returns:
- null for an empty source, or an
Object
of the giventype
deserialized from the array of bytes containing JSON. - Throws:
IllegalArgumentException
- if the giventype
is null.SerializationException
- if the array of bytes cannot be deserialized as an instance of the giventype
-
configure
public GenericJackson2JsonRedisSerializer configure(Consumer<com.fasterxml.jackson.databind.ObjectMapper> objectMapperConfigurer) Deprecated, for removal: This API element is subject to removal in a future version.Builder method used to configure and customize the internal JacksonObjectMapper
created by thisGenericJackson2JsonRedisSerializer
and used to de/serializeobjects
as JSON.- Parameters:
objectMapperConfigurer
-Consumer
used to configure and customize the internalObjectMapper
; must not be null.- Returns:
- this
GenericJackson2JsonRedisSerializer
. - Throws:
IllegalArgumentException
- if theConsumer
used to configure and customize the internalObjectMapper
is null.- Since:
- 3.1.5
-
resolveType
protected com.fasterxml.jackson.databind.JavaType resolveType(byte[] source, Class<?> type) throws IOException Deprecated, for removal: This API element is subject to removal in a future version.- Throws:
IOException
-
GenericJackson3JsonRedisSerializer