Interface Serializer

All Known Implementing Classes:
GsonSerializer, KryoSerializer

public interface Serializer

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 Type
    Method
    Description
    deserialize(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 Actor
    byte[]
    serialize(Message message)
    Serialize a Message to a byte array
    byte[]
    serializeField(Object fieldValue)
    Serialize a @Save field of an Actor
  • Method Details

    • serializeField

      byte[] serializeField(Object fieldValue)
      Serialize a @Save field of an Actor
      Parameters:
      fieldValue -
      Returns:
      Byte array
    • deserializeField

      Object deserializeField(byte[] source, Class<?> fieldClass)
      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

      byte[] serialize(Actor actor)
      Serialize the @Save fields of an Actor
      Parameters:
      actor -
      Returns:
    • deserialize

      void deserialize(byte[] source, Actor actor)
      Deserialize the @Save fields of an Actor into an existing actor.
      Parameters:
      source -
      actor -
    • serialize

      byte[] serialize(Message message)
      Serialize a Message to a byte array
      Parameters:
      message -
      Returns:
    • deserialize

      Message deserialize(byte[] source)
      Deserialize a byte array into a new Message.
      Parameters:
      source -
      Returns:
      A newly constructed Message