Class OxmSerializer
java.lang.Object
org.springframework.data.redis.serializer.OxmSerializer
- All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean
,RedisSerializer<Object>
public class OxmSerializer
extends Object
implements org.springframework.beans.factory.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
(org.springframework.oxm.Marshaller marshaller, org.springframework.oxm.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
(org.springframework.oxm.Marshaller marshaller) void
setUnmarshaller
(org.springframework.oxm.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
public OxmSerializer(org.springframework.oxm.Marshaller marshaller, org.springframework.oxm.Unmarshaller unmarshaller) - Parameters:
marshaller
- must not be null.unmarshaller
- must not be null.
-
-
Method Details
-
setMarshaller
public void setMarshaller(org.springframework.oxm.Marshaller marshaller) - Parameters:
marshaller
- The marshaller to set.
-
setUnmarshaller
public void setUnmarshaller(org.springframework.oxm.Unmarshaller unmarshaller) - Parameters:
unmarshaller
- The unmarshaller to set.
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
-
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
-