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
ConstructorDescriptionCreates a new, uninitializedOxmSerializer
.OxmSerializer
(Marshaller marshaller, Unmarshaller unmarshaller) -
Method Summary
Modifier and TypeMethodDescriptionvoid
deserialize
(byte[] bytes) Deserialize an object from the given binary data.byte[]
Serialize the given object to binary data.void
setMarshaller
(Marshaller marshaller) void
setUnmarshaller
(Unmarshaller unmarshaller) 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
-
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:
afterPropertiesSet
in interfaceInitializingBean
-
serialize
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 null.
- Throws:
SerializationException
-
deserialize
Description copied from interface:RedisSerializer
Deserialize an object from the given binary data.- Specified by:
deserialize
in interfaceRedisSerializer<Object>
- Parameters:
bytes
- object binary representation. Can be null.- Returns:
- the equivalent object instance. Can be null.
- Throws:
SerializationException
-