public class KryoSerializer extends Serializer
This is the implementation of the Kryo based serialization for Dempsy.
It can be configured with registered classes using Spring by passing a
list of Registration
instances to the constructor.
The serializer will also pick up registrations from a file on the classpath
if it's provided. It will default to KRYO_REGISTRATION_FILE
but can be overridden by supplying the system property with the name
SYS_PROP_REGISTRAION_RESOURCE
.
Modifier and Type | Class and Description |
---|---|
class |
KryoSerializer.Holder |
Modifier and Type | Field and Description |
---|---|
static String |
KRYO_REGISTRATION_FILE |
static String |
SYS_PROP_REGISTRAION_RESOURCE |
Constructor and Description |
---|
KryoSerializer() |
KryoSerializer(boolean manageExactClasses)
Create an unconfigured default
KryoSerializer with no registered classes. |
KryoSerializer(boolean manageExactClasses,
KryoOptimizer optimizer,
Registration... regs)
Create an
KryoSerializer with the provided registrations and
Application specific Optimizer. |
KryoSerializer(boolean manageExactClasses,
Registration... regs)
Create an
KryoSerializer with the provided registrations. |
Modifier and Type | Method and Description |
---|---|
<T> T |
deserialize(MessageBufferInput data,
Class<T> clazz) |
protected KryoSerializer.Holder |
getKryoHolder() |
<T> void |
serialize(T object,
MessageBufferOutput buffer) |
void |
setKryoOptimizer(KryoOptimizer optimizer)
Set the optimizer.
|
void |
setKryoRegistrationRequired(boolean requireRegistration)
You can require Kryo to serialize only registered classes by passing '
true ' to setKryoRegistrationRequired. |
deserialize, serialize
public static final String KRYO_REGISTRATION_FILE
public static final String SYS_PROP_REGISTRAION_RESOURCE
public KryoSerializer()
public KryoSerializer(boolean manageExactClasses)
KryoSerializer
with no registered classes.
If you set manageExactClasses then the result of serializing and then deserializing
a class by referring to its superclass will result in the original class.
Otherwise the class passed to the deserialize call will be the actual class that's
deserialized.public KryoSerializer(boolean manageExactClasses, Registration... regs)
KryoSerializer
with the provided registrations.
This can be used from a Spring configuration.public KryoSerializer(boolean manageExactClasses, KryoOptimizer optimizer, Registration... regs)
KryoSerializer
with the provided registrations and
Application specific Optimizer. This can be used from a Spring configuration.public void setKryoOptimizer(KryoOptimizer optimizer)
optimizer
- public void setKryoRegistrationRequired(boolean requireRegistration)
true
' to setKryoRegistrationRequired. The default is 'false
'.public <T> void serialize(T object, MessageBufferOutput buffer) throws IOException
serialize
in class Serializer
IOException
public <T> T deserialize(MessageBufferInput data, Class<T> clazz) throws IOException
deserialize
in class Serializer
IOException
protected KryoSerializer.Holder getKryoHolder()
Copyright © 2018. All rights reserved.