public abstract class AbstractSerializationService extends Object implements InternalSerializationService
Modifier and Type | Class and Description |
---|---|
static class |
AbstractSerializationService.Builder<T extends AbstractSerializationService.Builder<T>> |
Modifier and Type | Field and Description |
---|---|
protected BufferPoolThreadLocal |
bufferPoolThreadLocal |
protected com.hazelcast.internal.serialization.impl.SerializerAdapter |
dataSerializerAdapter |
protected PartitioningStrategy |
globalPartitioningStrategy |
protected InputOutputFactory |
inputOutputFactory |
protected com.hazelcast.internal.serialization.impl.SerializerAdapter |
javaExternalizableAdapter |
protected com.hazelcast.internal.serialization.impl.SerializerAdapter |
javaSerializerAdapter |
protected ManagedContext |
managedContext |
protected com.hazelcast.internal.serialization.impl.SerializerAdapter |
nullSerializerAdapter |
protected com.hazelcast.internal.serialization.impl.SerializerAdapter |
portableSerializerAdapter |
VERSION_1
Modifier and Type | Method and Description |
---|---|
protected int |
calculatePartitionHash(Object obj,
PartitioningStrategy strategy) |
BufferObjectDataInput |
createObjectDataInput(byte[] data) |
BufferObjectDataInput |
createObjectDataInput(Data data) |
BufferObjectDataOutput |
createObjectDataOutput() |
BufferObjectDataOutput |
createObjectDataOutput(int size) |
void |
dispose()
Disposes this object and releases any data and/or resources associated
with it.
|
void |
disposeData(Data data) |
ByteOrder |
getByteOrder()
Returns the byte order used when serializing/deserializing objects.
|
ClassLoader |
getClassLoader() |
ManagedContext |
getManagedContext()
|
byte |
getVersion() |
<T> T |
readObject(ObjectDataInput in) |
<T> T |
readObject(ObjectDataInput in,
Class aClass) |
void |
register(Class type,
Serializer serializer) |
protected void |
registerConstant(Class type,
Serializer serializer) |
protected void |
registerConstant(Class type,
com.hazelcast.internal.serialization.impl.SerializerAdapter serializer) |
void |
registerGlobal(Serializer serializer) |
void |
registerGlobal(Serializer serializer,
boolean overrideJavaSerialization) |
protected boolean |
safeRegister(Class type,
Serializer serializer) |
protected boolean |
safeRegister(Class type,
com.hazelcast.internal.serialization.impl.SerializerAdapter serializer) |
protected com.hazelcast.internal.serialization.impl.SerializerAdapter |
serializerFor(int typeId) |
protected com.hazelcast.internal.serialization.impl.SerializerAdapter |
serializerFor(Object object) |
byte[] |
toBytes(Object obj)
Writes the obj to a byte array.
|
byte[] |
toBytes(Object obj,
int leftPadding,
boolean insertPartitionHash)
Writes an object to a byte-array.
|
<B extends Data> |
toData(Object obj)
Serializes an object to a
Data . |
<B extends Data> |
toData(Object obj,
PartitioningStrategy strategy)
Serializes an object to a
Data . |
<T> T |
toObject(Object object)
Deserializes an object.
|
<T> T |
toObject(Object object,
Class aClass)
Deserializes an object.
|
void |
writeObject(ObjectDataOutput out,
Object obj) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
convertData, createPortableReader, getPortableContext, toData, toData
protected final ManagedContext managedContext
protected final InputOutputFactory inputOutputFactory
protected final PartitioningStrategy globalPartitioningStrategy
protected final BufferPoolThreadLocal bufferPoolThreadLocal
protected com.hazelcast.internal.serialization.impl.SerializerAdapter dataSerializerAdapter
protected com.hazelcast.internal.serialization.impl.SerializerAdapter portableSerializerAdapter
protected final com.hazelcast.internal.serialization.impl.SerializerAdapter nullSerializerAdapter
protected com.hazelcast.internal.serialization.impl.SerializerAdapter javaSerializerAdapter
protected com.hazelcast.internal.serialization.impl.SerializerAdapter javaExternalizableAdapter
public final <B extends Data> B toData(Object obj)
SerializationService
Data
.
This method can safely be called with a Data
instance. In that case, that instance is returned.
If this method is called with null, null is returned.toData
in interface SerializationService
obj
- the object to serialize.public final <B extends Data> B toData(Object obj, PartitioningStrategy strategy)
SerializationService
Data
.
This method can safely be called with a Data
instance. In that case, that instance is returned.
If this method is called with null, null is returned.toData
in interface SerializationService
obj
- the object to serialize.strategy
- strategy is used to calculate partition ID of the resulting data see PartitioningStrategy
public byte[] toBytes(Object obj)
InternalSerializationService
SerializationService.toData(Object)
and
then calling Data.toByteArray()
. But it doesn't force a HeapData object being created.
IMPORTANT: The byte order used to serialize obj
's serializer type ID is always
ByteOrder.BIG_ENDIAN
.
toBytes
in interface InternalSerializationService
public byte[] toBytes(Object obj, int leftPadding, boolean insertPartitionHash)
InternalSerializationService
If you want to convert an object to a Data (or its byte representation) then you want to have the partition hash, because that is part of the Data-definition. But if you want to serialize an object to a byte-array and don't care for the Data partition-hash, the hash can be disabled.
IMPORTANT: The byte order used to serialize obj
's serializer type ID is the byte order
configured in SerializationConfig.getByteOrder()
.
toBytes
in interface InternalSerializationService
obj
- object to write to byte arrayleftPadding
- offset from beginning of byte array to start writing the object's bytesinsertPartitionHash
- true
to include the partition hash in the byte array, otherwise false
public final <T> T toObject(Object object)
SerializationService
toObject
in interface SerializationService
object
- the data to deserialize.public final <T> T toObject(Object object, Class aClass)
SerializationService
toObject
in interface SerializationService
object
- the data to deserialize.aClass
- The class to instantiate when deserializing the object.public final void writeObject(ObjectDataOutput out, Object obj)
writeObject
in interface InternalSerializationService
public final <T> T readObject(ObjectDataInput in)
readObject
in interface InternalSerializationService
public final <T> T readObject(ObjectDataInput in, Class aClass)
readObject
in interface InternalSerializationService
public void disposeData(Data data)
disposeData
in interface InternalSerializationService
public final BufferObjectDataInput createObjectDataInput(byte[] data)
createObjectDataInput
in interface InternalSerializationService
public final BufferObjectDataInput createObjectDataInput(Data data)
createObjectDataInput
in interface InternalSerializationService
public final BufferObjectDataOutput createObjectDataOutput(int size)
createObjectDataOutput
in interface InternalSerializationService
public BufferObjectDataOutput createObjectDataOutput()
createObjectDataOutput
in interface InternalSerializationService
public final ClassLoader getClassLoader()
getClassLoader
in interface InternalSerializationService
public final ManagedContext getManagedContext()
SerializationService
getManagedContext
in interface SerializationService
public ByteOrder getByteOrder()
InternalSerializationService
serializerTypeId
: when using InternalSerializationService.toBytes(Object)
, the object's serializerTypeId
is serialized
always in ByteOrder.BIG_ENDIAN
, while when using InternalSerializationService.toBytes(Object, int, boolean)
, the configured
byte order is used. Inner objects (for example those serialized within an
IdentifiedDataSerializable
's writeData(ObjectDataOutput)
with
ObjectDataOutput.writeObject(Object)
) always use the configured byte order.getByteOrder
in interface InternalSerializationService
ByteOrder
which is configured for this InternalSerializationService
.SerializationConfig.setByteOrder(ByteOrder)
,
SerializationConfig.setUseNativeByteOrder(boolean)
,
SerializationConfig.setAllowUnsafe(boolean)
public byte getVersion()
getVersion
in interface InternalSerializationService
public void dispose()
Disposable
dispose
in interface Disposable
public final void register(Class type, Serializer serializer)
public final void registerGlobal(Serializer serializer)
public final void registerGlobal(Serializer serializer, boolean overrideJavaSerialization)
protected final int calculatePartitionHash(Object obj, PartitioningStrategy strategy)
protected final boolean safeRegister(Class type, Serializer serializer)
protected final boolean safeRegister(Class type, com.hazelcast.internal.serialization.impl.SerializerAdapter serializer)
protected final void registerConstant(Class type, Serializer serializer)
protected final void registerConstant(Class type, com.hazelcast.internal.serialization.impl.SerializerAdapter serializer)
protected final com.hazelcast.internal.serialization.impl.SerializerAdapter serializerFor(int typeId)
protected final com.hazelcast.internal.serialization.impl.SerializerAdapter serializerFor(Object object)
Copyright © 2021 Hazelcast, Inc.. All Rights Reserved.