akka.serialization
Class Serialization

java.lang.Object
  extended by akka.serialization.Serialization
All Implemented Interfaces:
Extension

public class Serialization
extends java.lang.Object
implements Extension

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.


Nested Class Summary
static class Serialization.Settings
           
 
Constructor Summary
Serialization(ExtendedActorSystem system)
           
 
Method Summary
 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<akka.serialization.Serialization.Information> currentTransportInformation()
          This holds a reference to the current transport serialization information used for serializing local actor refs.
<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.
<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 and the optional ClassLoader ot load it into.
 Serializer findSerializerFor(java.lang.Object o)
          Returns the Serializer configured for the given object, returns the NullSerializer if it's null.
 LoggingAdapter log()
           
 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.
static java.lang.String serializedActorPath(ActorRef actorRef)
          The serialized path of an actorRef, based on the current transport serialization information.
 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’s DynamicAccess.
 Serialization.Settings settings()
           
 ExtendedActorSystem system()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Serialization

public Serialization(ExtendedActorSystem system)
Method Detail

currentTransportInformation

public static scala.util.DynamicVariable<akka.serialization.Serialization.Information> currentTransportInformation()
This holds a reference to the current transport serialization information used for serializing local actor refs. INTERNAL API


serializedActorPath

public static java.lang.String serializedActorPath(ActorRef actorRef)
The serialized path of an actorRef, based on the current transport serialization information. If there is no external address available for the requested address then the systems default address will be used.


system

public ExtendedActorSystem system()

settings

public Serialization.Settings settings()

log

public LoggingAdapter log()

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.


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 and the optional ClassLoader ot load it into. Returns either the resulting object or an Exception if one was thrown.


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. You can specify an optional ClassLoader to load the object into. Returns either the resulting object or an Exception if one was thrown.


findSerializerFor

public Serializer findSerializerFor(java.lang.Object o)
Returns the Serializer configured for the given object, returns the NullSerializer if it's null.

Throws:
ConfigurationException - if no serialization-bindings is configured for the class of the object

serializerFor

public Serializer serializerFor(java.lang.Class<?> clazz)
Returns the configured Serializer for the given Class. The configured Serializer is used if the configured class isAssignableFrom from the clazz, 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

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’s DynamicAccess.


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.


serializerByIdentity

public scala.collection.immutable.Map<java.lang.Object,Serializer> serializerByIdentity()
Maps from a Serializer Identity (Int) to a Serializer instance (optimization)