Package akka.serialization
Class Serialization
- java.lang.Object
-
- akka.serialization.Serialization
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Serialization.Information
Serialization information needed for serializing local actor refs, or if serializer library e.g.static class
Serialization.Information$
static class
Serialization.Settings
-
Constructor Summary
Constructors Constructor Description Serialization(ExtendedActorSystem system)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
AllowJavaSerialization()
scala.collection.immutable.Seq<scala.Tuple2<java.lang.Class<?>,Serializer>>
bindings()
bindings is a Seq of tuple representing the mapping from Class to Serializer.static scala.util.DynamicVariable<Serialization.Information>
currentTransportInformation()
INTERNAL API: This holds a reference to the current transport serialization information used for serializing local actor refs, or if serializer library e.g.scala.util.Try<java.lang.Object>
deserialize(byte[] bytes, int serializerId, java.lang.String manifest)
Deserializes the given array of bytes using the specified serializer id, using the optional type hint to the Serializer.<T> scala.util.Try<T>
deserialize(byte[] bytes, int serializerId, scala.Option<java.lang.Class<? extends T>> clazz)
Deserializes the given array of bytes using the specified serializer id, using the optional type hint to the Serializer.<T> scala.util.Try<T>
deserialize(byte[] bytes, java.lang.Class<T> clazz)
Deserializes the given array of bytes using the specified type to look up what Serializer should be used.java.lang.Object
deserializeByteBuffer(java.nio.ByteBuffer buf, int serializerId, java.lang.String manifest)
Deserializes the given ByteBuffer of bytes using the specified serializer id, using the optional type hint to the Serializer.Serializer
findSerializerFor(java.lang.Object o)
Returns the Serializer configured for the given object, returns the NullSerializer if it's null.static Serialization.Information
getCurrentTransportInformation()
Gets the serialization information from aThreadLocal
that was assigned viawithTransportInformation(akka.actor.ExtendedActorSystem, scala.Function0<T>)
.LoggingAdapter
log()
Serialization.Information
serializationInformation()
INTERNAL APIscala.util.Try<byte[]>
serialize(java.lang.Object o)
Serializes the given AnyRef/java.lang.Object according to the Serialization configuration to either an Array of Bytes or an Exception if one was thrown.static java.lang.String
serializedActorPath(ActorRef actorRef)
scala.collection.immutable.Map<java.lang.Object,Serializer>
serializerByIdentity()
Maps from a Serializer Identity (Int) to a Serializer instance (optimization)Serializer
serializerFor(java.lang.Class<?> clazz)
Returns the configured Serializer for the given Class.scala.util.Try<Serializer>
serializerOf(java.lang.String serializerFQN)
Tries to load the specified Serializer by the fully-qualified name; the actual loading is performed by the system’sDynamicAccess
.Serialization.Settings
settings()
boolean
shouldWarnAboutJavaSerializer(java.lang.Class<?> serializedClass, Serializer serializer)
INTERNAL APIExtendedActorSystem
system()
static <T> T
withTransportInformation(ExtendedActorSystem system, scala.Function0<T> f)
-
-
-
Constructor Detail
-
Serialization
public Serialization(ExtendedActorSystem system)
-
-
Method Detail
-
currentTransportInformation
public static scala.util.DynamicVariable<Serialization.Information> currentTransportInformation()
INTERNAL API: This holds a reference to the current transport serialization information used for serializing local actor refs, or if serializer library e.g. custom serializer/deserializer in Jackson need access to the currentActorSystem
.- Returns:
- (undocumented)
-
serializedActorPath
public static java.lang.String serializedActorPath(ActorRef actorRef)
-
withTransportInformation
public static <T> T withTransportInformation(ExtendedActorSystem system, scala.Function0<T> f)
-
getCurrentTransportInformation
public static Serialization.Information getCurrentTransportInformation()
Gets the serialization information from aThreadLocal
that was assigned viawithTransportInformation(akka.actor.ExtendedActorSystem, scala.Function0<T>)
. The information is needed for serializing local actor refs, or if serializer library e.g. custom serializer/deserializer in Jackson need access to the currentActorSystem
.- Returns:
- (undocumented)
- Throws:
java.lang.IllegalStateException
- if the information was not set
-
system
public ExtendedActorSystem system()
-
settings
public Serialization.Settings settings()
-
AllowJavaSerialization
public boolean AllowJavaSerialization()
-
log
public LoggingAdapter log()
-
serializationInformation
public Serialization.Information serializationInformation()
INTERNAL API
-
serialize
public scala.util.Try<byte[]> serialize(java.lang.Object o)
Serializes the given AnyRef/java.lang.Object according to the Serialization configuration to either an Array of Bytes or an Exception if one was thrown.- Parameters:
o
- (undocumented)- Returns:
- (undocumented)
-
deserialize
public <T> scala.util.Try<T> deserialize(byte[] bytes, int serializerId, scala.Option<java.lang.Class<? extends T>> clazz)
Deserializes the given array of bytes using the specified serializer id, using the optional type hint to the Serializer. Returns either the resulting object or an Exception if one was thrown.- Parameters:
bytes
- (undocumented)serializerId
- (undocumented)clazz
- (undocumented)- Returns:
- (undocumented)
-
deserialize
public scala.util.Try<java.lang.Object> deserialize(byte[] bytes, int serializerId, java.lang.String manifest)
Deserializes the given array of bytes using the specified serializer id, using the optional type hint to the Serializer. Returns either the resulting object or an Exception if one was thrown.- Parameters:
bytes
- (undocumented)serializerId
- (undocumented)manifest
- (undocumented)- Returns:
- (undocumented)
-
deserializeByteBuffer
public java.lang.Object deserializeByteBuffer(java.nio.ByteBuffer buf, int serializerId, java.lang.String manifest) throws java.io.NotSerializableException
Deserializes the given ByteBuffer of bytes using the specified serializer id, using the optional type hint to the Serializer. Returns either the resulting object or throws an exception if deserialization fails.- Parameters:
buf
- (undocumented)serializerId
- (undocumented)manifest
- (undocumented)- Returns:
- (undocumented)
- Throws:
java.io.NotSerializableException
-
deserialize
public <T> scala.util.Try<T> deserialize(byte[] bytes, java.lang.Class<T> clazz)
Deserializes the given array of bytes using the specified type to look up what Serializer should be used. Returns either the resulting object or an Exception if one was thrown.- Parameters:
bytes
- (undocumented)clazz
- (undocumented)- Returns:
- (undocumented)
-
findSerializerFor
public Serializer findSerializerFor(java.lang.Object o)
Returns the Serializer configured for the given object, returns the NullSerializer if it's null.Throws akka.ConfigurationException if no
serialization-bindings
is configured for the class of the object.- Parameters:
o
- (undocumented)- Returns:
- (undocumented)
-
serializerFor
public Serializer serializerFor(java.lang.Class<?> clazz) throws java.io.NotSerializableException
Returns the configured Serializer for the given Class. The configured Serializer is used if the configured classisAssignableFrom
from theclazz
, i.e. the configured class is a super class or implemented interface. In case of ambiguity it is primarily using the most specific configured class, and secondly the entry configured first.Throws java.io.NotSerializableException if no
serialization-bindings
is configured for the class.- Parameters:
clazz
- (undocumented)- Returns:
- (undocumented)
- Throws:
java.io.NotSerializableException
-
serializerOf
public scala.util.Try<Serializer> serializerOf(java.lang.String serializerFQN)
Tries to load the specified Serializer by the fully-qualified name; the actual loading is performed by the system’sDynamicAccess
.- Parameters:
serializerFQN
- (undocumented)- Returns:
- (undocumented)
-
bindings
public scala.collection.immutable.Seq<scala.Tuple2<java.lang.Class<?>,Serializer>> bindings()
bindings is a Seq of tuple representing the mapping from Class to Serializer. It is primarily ordered by the most specific classes first, and secondly in the configured order.- Returns:
- (undocumented)
-
serializerByIdentity
public scala.collection.immutable.Map<java.lang.Object,Serializer> serializerByIdentity()
Maps from a Serializer Identity (Int) to a Serializer instance (optimization)- Returns:
- (undocumented)
-
shouldWarnAboutJavaSerializer
public boolean shouldWarnAboutJavaSerializer(java.lang.Class<?> serializedClass, Serializer serializer)
INTERNAL API- Parameters:
serializedClass
- (undocumented)serializer
- (undocumented)- Returns:
- (undocumented)
-
-