Class JsonInstanceSerializer<T>

java.lang.Object
org.apache.curator.x.discovery.details.JsonInstanceSerializer<T>
All Implemented Interfaces:
InstanceSerializer<T>

public class JsonInstanceSerializer<T> extends Object implements InstanceSerializer<T>
A serializer that uses Jackson to serialize/deserialize as JSON. IMPORTANT: The instance payload must support Jackson
  • Constructor Details

    • JsonInstanceSerializer

      public JsonInstanceSerializer(Class<T> payloadClass)
      CURATOR-275 introduced a new field into ServiceInstance. This caused a potential UnrecognizedPropertyException in older clients that read newly serialized ServiceInstances. Therefore the default behavior of JsonInstanceSerializer has been changed to NOT serialize the enabled field. If you wish to use that field, use the alternate constructor JsonInstanceSerializer(Class, boolean) and pass true for compatibleSerializationMode. Note: future versions of Curator may change this behavior.
      Parameters:
      payloadClass - used to validate payloads when deserializing
    • JsonInstanceSerializer

      public JsonInstanceSerializer(Class<T> payloadClass, boolean compatibleSerializationMode)
      CURATOR-275 introduced a new field into ServiceInstance. This caused a potential UnrecognizedPropertyException in older clients that read newly serialized ServiceInstances. If you are susceptible to this you should set the serializer to be an instance of JsonInstanceSerializer with compatibleSerializationMode set to true. IMPORTANT: when this is done, the new enabled field of ServiceInstance is not serialized. If however you do want to use the enabled field, set compatibleSerializationMode to false.
      Parameters:
      payloadClass - used to validate payloads when deserializing
      compatibleSerializationMode - pass true to serialize in a manner that supports clients pre-CURATOR-275
  • Method Details