Class OxmSerializer
java.lang.Object
org.springframework.data.redis.serializer.OxmSerializer
- All Implemented Interfaces:
InitializingBean, RedisSerializer<Object>
Serializer adapter on top of Spring's O/X Mapping. Delegates serialization/deserialization to OXM
Marshaller
and Unmarshaller. Note: null objects are serialized as empty arrays and vice versa.- Author:
- Costin Leau, Mark Paluch
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new, uninitializedOxmSerializer.OxmSerializer(Marshaller marshaller, Unmarshaller unmarshaller) -
Method Summary
Modifier and TypeMethodDescriptionvoid@Nullable Objectdeserialize(byte @Nullable [] bytes) Deserialize an object from the given binary data.byte[]Serialize the given object to binary data.voidsetMarshaller(Marshaller marshaller) voidsetUnmarshaller(Unmarshaller unmarshaller) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface RedisSerializer
canSerialize, getTargetType
-
Constructor Details
-
OxmSerializer
public OxmSerializer()Creates a new, uninitializedOxmSerializer. RequiressetMarshaller(Marshaller)andsetUnmarshaller(Unmarshaller)to be set before this serializer can be used. -
OxmSerializer
- Parameters:
marshaller- must not be null.unmarshaller- must not be null.
-
-
Method Details
-
setMarshaller
- Parameters:
marshaller- The marshaller to set.
-
setUnmarshaller
- Parameters:
unmarshaller- The unmarshaller to set.
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSetin interfaceInitializingBean
-
serialize
Description copied from interface:RedisSerializerSerialize the given object to binary data.- Specified by:
serializein 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
Description copied from interface:RedisSerializerDeserialize an object from the given binary data.- Specified by:
deserializein interfaceRedisSerializer<Object>- Parameters:
bytes- object binary representation. Can be null.- Returns:
- the equivalent object instance. Can be null.
- Throws:
SerializationException
-