package serialization
- Alphabetic
- Public
- Protected
Type Members
- trait AsyncSerializer extends AnyRef
Serializer that supports async serialization.
Serializer that supports async serialization.
Only used for Akka persistence journals that explicitly support async serializers.
Implementations should typically extend AsyncSerializerWithStringManifest or AsyncSerializerWithStringManifestCS that delegates synchronous calls to their async equivalents.
- abstract class AsyncSerializerWithStringManifest extends SerializerWithStringManifest with AsyncSerializer
Scala API: Async serializer with string manifest that delegates synchronous calls to the asynchronous calls and blocks.
- abstract class AsyncSerializerWithStringManifestCS extends AsyncSerializerWithStringManifest
Java API: Async serializer with string manifest that delegates synchronous calls to the asynchronous calls and blocks.
- trait BaseSerializer extends Serializer
Base serializer trait with serialization identifiers configuration contract, when globally unique serialization identifier is configured in the
reference.conf
. - class ByteArraySerializer extends BaseSerializer with ByteBufferSerializer
This is a special Serializer that Serializes and deserializes byte arrays only, (just returns the byte array unchanged/uncopied)
- trait ByteBufferSerializer extends AnyRef
Serializer between an object and a
ByteBuffer
representing that object.Serializer between an object and a
ByteBuffer
representing that object.Implementations should typically extend SerializerWithStringManifest and in addition to the
ByteBuffer
basedtoBinary
andfromBinary
methods also implement the array basedtoBinary
andfromBinary
methods. The array based methods will be used whenByteBuffer
is not used, e.g. in Akka Persistence.Note that the array based methods can for example be implemented by delegation like this:
// you need to know the maximum size in bytes of the serialized messages val pool = new akka.io.DirectByteBufferPool(defaultBufferSize = 1024 * 1024, maxPoolEntries = 10) // Implement this method for compatibility with `SerializerWithStringManifest`. override def toBinary(o: AnyRef): Array[Byte] = { val buf = pool.acquire() try { toBinary(o, buf) buf.flip() val bytes = new Array[Byte](buf.remaining) buf.get(bytes) bytes } finally { pool.release(buf) } } // Implement this method for compatibility with `SerializerWithStringManifest`. override def fromBinary(bytes: Array[Byte], manifest: String): AnyRef = fromBinary(ByteBuffer.wrap(bytes), manifest)
- final case class DisabledJavaSerializer(system: ExtendedActorSystem) extends Serializer with ByteBufferSerializer with Product with Serializable
This Serializer is used when
akka.actor.java-serialization = off
- abstract class JSerializer extends Serializer
Java API for creating a Serializer: make sure to include a constructor which takes exactly one argument of type akka.actor.ExtendedActorSystem, because that is the preferred constructor which will be invoked when reflectively instantiating the JSerializer (also possible with empty constructor).
- class JavaSerializer extends BaseSerializer
This Serializer uses standard Java Serialization
- class NullSerializer extends Serializer
This is a special Serializer that Serializes and deserializes nulls only
- class Serialization extends Extension
Serialization module.
Serialization module. Contains methods for serialization and deserialization as well as locating a Serializer for a particular class as defined in the mapping in the configuration.
- final class SerializationSetup extends Setup
Setup for the serialization subsystem, constructor is *Internal API*, use factories in SerializationSetup
- trait Serializer extends AnyRef
A Serializer represents a bimap between an object and an array of bytes representing that object.
A Serializer represents a bimap between an object and an array of bytes representing that object.
Serializers are loaded using reflection during akka.actor.ActorSystem start-up, where constructors are tried in order:
- taking exactly one argument of type akka.actor.ExtendedActorSystem; this should be the preferred one because all reflective loading of classes during deserialization should use ExtendedActorSystem.dynamicAccess (see akka.actor.DynamicAccess)
- taking exactly one argument of type akka.actor.ActorSystem
- taking exactly one argument of type akka.actor.ClassicActorSystemProvider
- without arguments
- taking two arguments of type akka.actor.ExtendedActorSystem and
String
where the secondString
argument is the binding name - taking two arguments of type akka.actor.ActorSystem and
String
where the secondString
argument is the binding name - taking two arguments of type akka.actor.ClassicActorSystemProvider and
String
where the secondString
argument is the binding name
Be sure to always use the akka.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.
- final class SerializerDetails extends AnyRef
Constructor is internal API: Use the factories SerializerDetails#create or SerializerDetails#apply to construct
- abstract class SerializerWithStringManifest extends Serializer
A Serializer represents a bimap between an object and an array of bytes representing that object.
A Serializer represents a bimap between an object and an array of bytes representing that object.
For serialization of data that need to evolve over time the
SerializerWithStringManifest
is recommended instead of Serializer because the manifest (type hint) is aString
instead of aClass
. That means that the class can be moved/removed and the serializer can still deserialize old data by matching on theString
. This is especially useful for Akka Persistence.The manifest string can also encode a version number that can be used in
fromBinary
to deserialize in different ways to migrate old data to new domain objects.If the data was originally serialized with Serializer and in a later version of the system you change to
SerializerWithStringManifest
the manifest string will be the full class name if you usedincludeManifest=true
, otherwise it will be the empty string.Serializers are loaded using reflection during akka.actor.ActorSystem start-up, where constructors are tried in order:
- taking exactly one argument of type akka.actor.ExtendedActorSystem; this should be the preferred one because all reflective loading of classes during deserialization should use ExtendedActorSystem.dynamicAccess (see akka.actor.DynamicAccess)
- taking exactly one argument of type akka.actor.ActorSystem
- taking exactly one argument of type akka.actor.ClassicActorSystemProvider
- without arguments
- taking two arguments of type akka.actor.ExtendedActorSystem and
String
where the secondString
argument is the binding name - taking two arguments of type akka.actor.ActorSystem and
String
where the secondString
argument is the binding name - taking two arguments of type akka.actor.ClassicActorSystemProvider and
String
where the secondString
argument is the binding name
Be sure to always use the akka.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.
Value Members
- object BaseSerializer
- object DisabledJavaSerializer extends Serializable
- object JavaSerializer
- object NullSerializer extends NullSerializer
- object Serialization
- Annotations
- @ccompatUsedUntil213()
- object SerializationExtension extends ExtensionId[Serialization] with ExtensionIdProvider
SerializationExtension is an Akka Extension to interact with the Serialization that is built into Akka
- object SerializationSetup
- object SerializerDetails
- object Serializers