Interface Serializer
- All Known Implementing Classes:
GsonSerializer
,KryoSerializer
A Serializer is concerned with serializing and deserializing Actors and Messages. A Serializer typically requires Actor and Message class metadata which takes time to collect and parse. For this reason, A Serializer is instantiated for each concrete Actor class.
When serialization is called depends on the life-cycle of an Actor. In summary, an Actor's state is restored when the Actor is instantiated in response to receiving its first message. It will be saved either at the conclusion of processing a message or at another time depending on that Actor's semantics.
A Message is serialized as soon as it is "sent" by an Actor and deserialized by the receiving Actor.
In all cases the serialization occurs in the individual Actor's thread which means there are usually no concurrency issues except that the Actor and Message metadata should be static by the time any serialization occurs.
Serialization must be to or from a byte array.
-
Method Summary
Modifier and TypeMethodDescriptiondeserialize
(byte[] source) Deserialize a byte array into a new Message.void
deserialize
(byte[] source, Actor actor) Deserialize the @Save fields of an Actor into an existing actor.deserializeField
(byte[] source, Class<?> fieldClass) Deserialize the @Save fields of an Actor into an existing actor.byte[]
Serialize the @Save fields of an Actorbyte[]
Serialize a Message to a byte arraybyte[]
serializeField
(Object fieldValue) Serialize a @Save field of an Actor
-
Method Details
-
serializeField
Serialize a @Save field of an Actor- Parameters:
fieldValue
-- Returns:
- Byte array
-
deserializeField
Deserialize the @Save fields of an Actor into an existing actor.- Parameters:
source
-fieldClass
- Class of the field that we're returning- Returns:
- An object containing the field value
-
serialize
Serialize the @Save fields of an Actor- Parameters:
actor
-- Returns:
-
deserialize
Deserialize the @Save fields of an Actor into an existing actor.- Parameters:
source
-actor
-
-
serialize
Serialize a Message to a byte array- Parameters:
message
-- Returns:
-
deserialize
Deserialize a byte array into a new Message.- Parameters:
source
-- Returns:
- A newly constructed Message
-