public abstract class Serializer
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static java.util.logging.Logger |
log |
Constructor and Description |
---|
Serializer() |
Modifier and Type | Method and Description |
---|---|
static Serializer |
getExactSerializer(java.lang.Class cls) |
static SerializerRegistration |
getExactSerializerRegistration(java.lang.Class cls) |
static Serializer |
getSerializer(java.lang.Class cls) |
static Serializer |
getSerializer(java.lang.Class cls,
boolean failOnMiss) |
static SerializerRegistration |
getSerializerRegistration(java.lang.Class cls) |
static SerializerRegistration |
getSerializerRegistration(java.lang.Class cls,
boolean failOnMiss) |
static java.util.Collection<SerializerRegistration> |
getSerializerRegistrations() |
static void |
initialize() |
void |
initialize(java.lang.Class clazz)
Registration for when a serializer may need to cache something.
|
static boolean |
isReadOnly() |
static SerializerRegistration |
readClass(java.nio.ByteBuffer buffer)
Read the class from given buffer and return its SerializerRegistration.
|
static java.lang.Object |
readClassAndObject(java.nio.ByteBuffer buffer)
Read the class and the object.
|
abstract <T> T |
readObject(java.nio.ByteBuffer data,
java.lang.Class<T> c)
Read an object from the buffer, effectively deserializing it.
|
static SerializerRegistration |
registerClass(java.lang.Class cls) |
static SerializerRegistration |
registerClass(java.lang.Class cls,
boolean failOnMiss)
Registers the specified class.
|
static SerializerRegistration |
registerClass(java.lang.Class cls,
Serializer serializer) |
static void |
registerClasses(java.lang.Class... classes) |
static SerializerRegistration |
registerClassForId(short id,
java.lang.Class cls,
Serializer serializer)
Directly registers a class for a specific ID.
|
static SerializerRegistration[] |
registerPackage(java.lang.String pkgName)
Deprecated.
This cannot be implemented in a reasonable way that works in
all deployment methods.
|
static void |
setReadOnly(boolean b)
Can put the registry in a read-only state such that additional attempts
to register classes will fail.
|
static void |
setStrictRegistration(boolean b)
When set to true, classes that do not have intrinsic IDs in their
@Serializable will not be auto-registered during write. |
static SerializerRegistration |
writeClass(java.nio.ByteBuffer buffer,
java.lang.Class type)
Write a class and return its SerializerRegistration.
|
static void |
writeClassAndObject(java.nio.ByteBuffer buffer,
java.lang.Object object)
Write the class and object.
|
abstract void |
writeObject(java.nio.ByteBuffer buffer,
java.lang.Object object)
Write an object to the buffer, effectively serializing it.
|
public static void initialize()
public static void setStrictRegistration(boolean b)
@Serializable
will not be auto-registered during write. Defaults
to true since this is almost never desired behavior with the way
this code works. Set to false to get the old permissive behavior.public static SerializerRegistration registerClass(java.lang.Class cls)
public static void registerClasses(java.lang.Class... classes)
public static void setReadOnly(boolean b)
public static boolean isReadOnly()
public static SerializerRegistration registerClassForId(short id, java.lang.Class cls, Serializer serializer)
public static SerializerRegistration registerClass(java.lang.Class cls, boolean failOnMiss)
@Deprecated public static SerializerRegistration[] registerPackage(java.lang.String pkgName)
public static SerializerRegistration registerClass(java.lang.Class cls, Serializer serializer)
public static Serializer getExactSerializer(java.lang.Class cls)
public static Serializer getSerializer(java.lang.Class cls)
public static Serializer getSerializer(java.lang.Class cls, boolean failOnMiss)
public static java.util.Collection<SerializerRegistration> getSerializerRegistrations()
public static SerializerRegistration getExactSerializerRegistration(java.lang.Class cls)
public static SerializerRegistration getSerializerRegistration(java.lang.Class cls)
public static SerializerRegistration getSerializerRegistration(java.lang.Class cls, boolean failOnMiss)
public static SerializerRegistration readClass(java.nio.ByteBuffer buffer)
buffer
- The buffer to read from.public static java.lang.Object readClassAndObject(java.nio.ByteBuffer buffer) throws java.io.IOException
buffer
- Buffer to read from.java.io.IOException
- If serialization failed.public static SerializerRegistration writeClass(java.nio.ByteBuffer buffer, java.lang.Class type) throws java.io.IOException
buffer
- The buffer to write the given class to.type
- The class to write.java.io.IOException
public static void writeClassAndObject(java.nio.ByteBuffer buffer, java.lang.Object object) throws java.io.IOException
buffer
- The buffer to write to.object
- The object to write.java.io.IOException
- If serializing fails.public abstract <T> T readObject(java.nio.ByteBuffer data, java.lang.Class<T> c) throws java.io.IOException
data
- The buffer to read from.c
- The class of the object.java.io.IOException
- If deserializing fails.public abstract void writeObject(java.nio.ByteBuffer buffer, java.lang.Object object) throws java.io.IOException
buffer
- The buffer to write to.object
- The object to serialize.java.io.IOException
- If serializing fails.public void initialize(java.lang.Class clazz)
clazz
- The class that has been registered to the serializer.