ValueSerializer (Apache Geode 1.6.0)
Date: 2018-04-23

org.apache.geode.protocol.serialization

## Interface ValueSerializer

-     @Experimental
      public interface ValueSerializer

  Interface for controlling serialization format of all values transmitted using the protobuf based client-server protocol. To use a custom format, implement this interface and register your format by adding a META-INF/services/org.apache.geode.protocol.serialization.ValueSerializer file that contains the full qualified name of your serializer. It will be loaded and registered using Java's `ServiceLoader` mechanism. Clients can than elect to use the registered format by sending a HandshakeRequest with and setting the valueFormat field in the request to match the string returned by `getID()` If clients elect to use this ValueSerializer, all values that are sent as an EncodedValue can be sent as EncodedValue.customObjectResult. The server will use the `deserialize(ByteString)` method to deserialize them. When the server is sending values to the client, it will use `serialize(Object)` to serialize the value and send the response to the client as a EncodedValue.customObjectResult. Implementations should be *threadsafe*. No guarantees are made about whether the server will create one or more instances of this serializer or how they will be shared amongst server threads. `init(Cache)` will be called before the `serialize(Object)` and `deserialize(ByteString)`.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.Object` | `deserialize(com.google.protobuf.ByteString bytes)` Deserialize bytes that are sent from the client into an object.
    `java.lang.String` | `getID()` Unique identifier for this serializer.
    `void` | `init(Cache cache)` Initialize this serializer.
    `com.google.protobuf.ByteString` | `serialize(java.lang.Object object)` Serialize an object into bytes that can be sent to a client.
    `default boolean` | `supportsPrimitives()` True if this serializer wants to serialize all values, including primitives like numbers and strings that can be sent as one of the options in EncodedValue.

- - ### Method Detail

    - #### serialize

          com.google.protobuf.ByteString serialize(java.lang.Object object)
                                            throws java.io.IOException

      Serialize an object into bytes that can be sent to a client.
      Parameters:
        `object` - Object to serialize, which may be null if `is true`. If the object to be sent is serialized in PDX form, this object may be a `PdxInstance`, even if `GemFireCache.getPdxReadSerialized()` is false
      Returns:
        the bytes to send to the client
      Throws:
        `java.io.IOException`

    - #### deserialize

          java.lang.Object deserialize(com.google.protobuf.ByteString bytes)
                                throws java.io.IOException,
                                       java.lang.ClassNotFoundException

      Deserialize bytes that are sent from the client into an object. This method can return a `PdxInstance` for PDX data to avoid having to actually have classes present on the server.
      Parameters:
        `bytes` - the bytes to deserialize. Will not be null.
      Returns:
        the deserialized version of the object
      Throws:
        `java.io.IOException`
        `java.lang.ClassNotFoundException`

    - #### init

          void init(Cache cache)

      Initialize this serializer. This method is called when a new connection is established that requests this format.
      Parameters:
        `cache` -

    - #### getID

          java.lang.String getID()

      Unique identifier for this serializer. Client's must set the valueFormat field of the HandshakeRequest to this value in order to use this format.

    - #### supportsPrimitives

          default boolean supportsPrimitives()

      True if this serializer wants to serialize all values, including primitives like numbers and strings that can be sent as one of the options in EncodedValue.
      Returns: