Package org.apache.pekko.serialization
Interface Serializer
- All Known Subinterfaces:
BaseSerializer
- All Known Implementing Classes:
AbstractSerializationSupport,AsyncSerializerWithStringManifest,AsyncSerializerWithStringManifestCS,ByteArraySerializer,ClusterMessageSerializer,DisabledJavaSerializer,JavaSerializer,JSerializer,MessageContainerSerializer,MessageSerializer,MessageSerializer,MiscMessageSerializer,NullSerializer,NullSerializer$,ProtobufSerializer,ReplicatedDataSerializer,ReplicatorMessageSerializer,SerializerWithStringManifest,ServiceKeySerializer,SnapshotSerializer,SystemMessageSerializer,TestJavaSerializer,TestSerializer
public interface Serializer
A Serializer represents a bimap between an object and an array of bytes representing that object.
Serializers are loaded using reflection during pekko.actor.ActorSystem
start-up, where two constructors are tried in order:
- taking exactly one argument of type
pekko.actor.ExtendedActorSystem; this should be the preferred one because all reflective loading of classes during deserialization should use ExtendedActorSystem.dynamicAccess (seepekko.actor.DynamicAccess), and - without arguments, which is only an option if the serializer does not load classes using reflection.
Be sure to always use the pekko.actor.DynamicAccess for loading classes! This is necessary to
avoid strange match errors and inequalities which arise from different class loaders loading
the same class.
-
Method Summary
Modifier and TypeMethodDescriptionfromBinary(byte[] bytes) Java API: deserialize without type hintfromBinary(byte[] bytes, Class<?> clazz) Java API: deserialize with type hintfromBinary(byte[] bytes, scala.Option<Class<?>> manifest) Produces an object from an array of bytes, with an optional type-hint; the class should be loaded using ActorSystem.dynamicAccess.intCompletely unique value to identify this implementation of Serializer, used to optimize network traffic.booleanReturns whether this serializer needs a manifest in the fromBinary methodbyte[]Serializes the given object into an Array of Byte.
-
Method Details
-
fromBinary
Produces an object from an array of bytes, with an optional type-hint; the class should be loaded using ActorSystem.dynamicAccess.- Throws:
NotSerializableException
-
fromBinary
Java API: deserialize without type hint -
fromBinary
Java API: deserialize with type hint- Throws:
NotSerializableException
-
identifier
int identifier()Completely unique value to identify this implementation of Serializer, used to optimize network traffic. Values from 0 to 40 are reserved for Pekko internal usage. -
includeManifest
boolean includeManifest()Returns whether this serializer needs a manifest in the fromBinary method -
toBinary
Serializes the given object into an Array of Byte.Note that the array must not be mutated by the serializer after it has been returned.
-