Package akka.serialization
Interface Serializer
-
- All Known Subinterfaces:
BaseSerializer
- All Known Implementing Classes:
AbstractSerializationSupport
,AsyncSerializerWithStringManifest
,AsyncSerializerWithStringManifestCS
,ByteArraySerializer
,ByteStringSerializer
,ClusterMessageSerializer
,DisabledJavaSerializer
,IntSerializer
,JavaSerializer
,JSerializer
,LongSerializer
,MessageContainerSerializer
,MessageSerializer
,MessageSerializer
,MiscMessageSerializer
,NullSerializer
,NullSerializer$
,PayloadSerializer
,ProtobufSerializer
,ReplicatedDataSerializer
,ReplicatorMessageSerializer
,SerializerWithStringManifest
,ServiceKeySerializer
,SnapshotSerializer
,StringSerializer
,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
ActorSystem
start-up, where constructors are tried in order:- taking exactly one argument of type
ExtendedActorSystem
; this should be the preferred one because all reflective loading of classes during deserialization should use ExtendedActorSystem.dynamicAccess (seeDynamicAccess
) - taking exactly one argument of type
ActorSystem
- taking exactly one argument of type
ClassicActorSystemProvider
- without arguments
- taking two arguments of type
ExtendedActorSystem
andString
where the secondString
argument is the binding name - taking two arguments of type
ActorSystem
andString
where the secondString
argument is the binding name - taking two arguments of type
ClassicActorSystemProvider
andString
where the secondString
argument is the binding name
Be sure to always use the
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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.Object
fromBinary(byte[] bytes)
Java API: deserialize without type hintjava.lang.Object
fromBinary(byte[] bytes, java.lang.Class<?> clazz)
Java API: deserialize with type hintjava.lang.Object
fromBinary(byte[] bytes, scala.Option<java.lang.Class<?>> manifest)
Produces an object from an array of bytes, with an optional type-hint; the class should be loaded using ActorSystem.dynamicAccess.int
identifier()
Completely unique value to identify this implementation of Serializer, used to optimize network traffic.boolean
includeManifest()
Returns whether this serializer needs a manifest in the fromBinary methodbyte[]
toBinary(java.lang.Object o)
Serializes the given object into an Array of Byte.
-
-
-
Method Detail
-
fromBinary
java.lang.Object fromBinary(byte[] bytes, scala.Option<java.lang.Class<?>> manifest) throws java.io.NotSerializableException
Produces an object from an array of bytes, with an optional type-hint; the class should be loaded using ActorSystem.dynamicAccess.- Throws:
java.io.NotSerializableException
-
fromBinary
java.lang.Object fromBinary(byte[] bytes)
Java API: deserialize without type hint
-
fromBinary
java.lang.Object fromBinary(byte[] bytes, java.lang.Class<?> clazz) throws java.io.NotSerializableException
Java API: deserialize with type hint- Throws:
java.io.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 Akka internal usage.
-
includeManifest
boolean includeManifest()
Returns whether this serializer needs a manifest in the fromBinary method
-
toBinary
byte[] toBinary(java.lang.Object o)
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.
-
-