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, waitconvertData, createPortableReader, getPortableContext, toData, toDataprotected 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)
SerializationServiceData.
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 SerializationServiceobj - the object to serialize.public final <B extends Data> B toData(Object obj, PartitioningStrategy strategy)
SerializationServiceData.
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 SerializationServiceobj - the object to serialize.strategy - strategy is used to calculate partition ID of the resulting data see PartitioningStrategypublic byte[] toBytes(Object obj)
InternalSerializationServiceSerializationService.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 InternalSerializationServicepublic byte[] toBytes(Object obj, int leftPadding, boolean insertPartitionHash)
InternalSerializationServiceIf 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 InternalSerializationServiceobj - 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 falsepublic final <T> T toObject(Object object)
SerializationServicetoObject in interface SerializationServiceobject - the data to deserialize.public final <T> T toObject(Object object, Class aClass)
SerializationServicetoObject in interface SerializationServiceobject - the data to deserialize.aClass - The class to instantiate when deserializing the object.public final void writeObject(ObjectDataOutput out, Object obj)
writeObject in interface InternalSerializationServicepublic final <T> T readObject(ObjectDataInput in)
readObject in interface InternalSerializationServicepublic final <T> T readObject(ObjectDataInput in, Class aClass)
readObject in interface InternalSerializationServicepublic void disposeData(Data data)
disposeData in interface InternalSerializationServicepublic final BufferObjectDataInput createObjectDataInput(byte[] data)
createObjectDataInput in interface InternalSerializationServicepublic final BufferObjectDataInput createObjectDataInput(Data data)
createObjectDataInput in interface InternalSerializationServicepublic final BufferObjectDataOutput createObjectDataOutput(int size)
createObjectDataOutput in interface InternalSerializationServicepublic BufferObjectDataOutput createObjectDataOutput()
createObjectDataOutput in interface InternalSerializationServicepublic final ClassLoader getClassLoader()
getClassLoader in interface InternalSerializationServicepublic final ManagedContext getManagedContext()
SerializationServicegetManagedContext in interface SerializationServicepublic ByteOrder getByteOrder()
InternalSerializationServiceserializerTypeId: 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 InternalSerializationServiceByteOrder which is configured for this InternalSerializationService.SerializationConfig.setByteOrder(ByteOrder),
SerializationConfig.setUseNativeByteOrder(boolean),
SerializationConfig.setAllowUnsafe(boolean)public byte getVersion()
getVersion in interface InternalSerializationServicepublic void dispose()
Disposabledispose in interface Disposablepublic 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 © 2018 Hazelcast, Inc.. All Rights Reserved.