Package org.apache.pekko.serialization
Class Serialization
- java.lang.Object
- 
- org.apache.pekko.serialization.Serialization
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classSerialization.InformationSerialization information needed for serializing local actor refs, or if serializer library e.g.static classSerialization.Information$static classSerialization.Settings
 - 
Constructor SummaryConstructors Constructor Description Serialization(ExtendedActorSystem system)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanAllowJavaSerialization()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)Deprecated.Use deserialize that accepts the `manifest` as a class name.<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.ObjectdeserializeByteBuffer(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.SerializerfindSerializerFor(java.lang.Object o)Returns the Serializer configured for the given object, returns the NullSerializer if it's null.static Serialization.InformationgetCurrentTransportInformation()Gets the serialization information from aThreadLocalthat was assigned viawithTransportInformation(org.apache.pekko.actor.ExtendedActorSystem, scala.Function0<T>).LoggingAdapterlog()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.StringserializedActorPath(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)SerializerserializerFor(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’spekko.actor.DynamicAccess.Serialization.Settingssettings()ExtendedActorSystemsystem()static <T> TwithTransportInformation(ExtendedActorSystem system, scala.Function0<T> f)Sets serialization information in aThreadLocaland runsf.
 
- 
- 
- 
Constructor Detail- 
Serializationpublic Serialization(ExtendedActorSystem system) 
 
- 
 - 
Method Detail- 
serializedActorPathpublic 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 in the givenActorRefthen the systems default address will be used and that is retrieved from the ThreadLocalSerialization.Informationthat was set withwithTransportInformation(org.apache.pekko.actor.ExtendedActorSystem, scala.Function0<T>).
 - 
withTransportInformationpublic static <T> T withTransportInformation(ExtendedActorSystem system, scala.Function0<T> f) Sets serialization information in aThreadLocaland runsf. 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. The currentSerialization.Informationcan be accessed withinfviagetCurrentTransportInformation().Pekko Remoting sets this value when serializing and deserializing messages, and when using the ordinary serializeanddeserializemethods inSerializationthe value is also set automatically.- Returns:
- value returned by f
 
 - 
getCurrentTransportInformationpublic static Serialization.Information getCurrentTransportInformation() Gets the serialization information from aThreadLocalthat was assigned viawithTransportInformation(org.apache.pekko.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.- Throws:
- java.lang.IllegalStateException- if the information was not set
 
 - 
systempublic ExtendedActorSystem system() 
 - 
settingspublic Serialization.Settings settings() 
 - 
AllowJavaSerializationpublic boolean AllowJavaSerialization() 
 - 
logpublic LoggingAdapter log() 
 - 
serializepublic 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.
 - 
deserializepublic <T> scala.util.Try<T> deserialize(byte[] bytes, int serializerId, scala.Option<java.lang.Class<? extends T>> clazz)Deprecated.Use deserialize that accepts the `manifest` as a class name. Since Akka 2.6.0.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.
 - 
deserializepublic 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.
 - 
deserializeByteBufferpublic java.lang.Object deserializeByteBuffer(java.nio.ByteBuffer buf, int serializerId, java.lang.String manifest) throws java.io.NotSerializableExceptionDeserializes 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.- Throws:
- java.io.NotSerializableException
 
 - 
deserializepublic <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.
 - 
findSerializerForpublic Serializer findSerializerFor(java.lang.Object o) Returns the Serializer configured for the given object, returns the NullSerializer if it's null.Throws org.apache.pekko.ConfigurationException if no serialization-bindingsis configured for the class of the object.
 - 
serializerForpublic 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 classisAssignableFromfrom 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-bindingsis configured for the class.- Throws:
- java.io.NotSerializableException
 
 - 
serializerOfpublic 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’spekko.actor.DynamicAccess.
 - 
serializerByIdentitypublic scala.collection.immutable.Map<java.lang.Object,Serializer> serializerByIdentity() Maps from a Serializer Identity (Int) to a Serializer instance (optimization)
 
- 
 
-