Class JsonInstanceSerializer<T>
java.lang.Object
org.apache.curator.x.discovery.details.JsonInstanceSerializer<T>
- All Implemented Interfaces:
InstanceSerializer<T>
A serializer that uses Jackson to serialize/deserialize as JSON. IMPORTANT: The instance
payload must support Jackson
-
Constructor Summary
ConstructorsConstructorDescriptionJsonInstanceSerializer(Class<T> payloadClass) CURATOR-275 introduced a new field intoServiceInstance.JsonInstanceSerializer(Class<T> payloadClass, boolean compatibleSerializationMode) CURATOR-275 introduced a new field intoServiceInstance. -
Method Summary
Modifier and TypeMethodDescriptiondeserialize(byte[] bytes) Deserialize a byte array into an instancebyte[]serialize(ServiceInstance<T> instance) Serialize an instance into bytes
-
Constructor Details
-
JsonInstanceSerializer
CURATOR-275 introduced a new field intoServiceInstance. This caused a potentialUnrecognizedPropertyExceptionin older clients that read newly serialized ServiceInstances. Therefore the default behavior of JsonInstanceSerializer has been changed to NOT serialize theenabledfield. If you wish to use that field, use the alternate constructorJsonInstanceSerializer(Class, boolean)and pass true forcompatibleSerializationMode. Note: future versions of Curator may change this behavior.- Parameters:
payloadClass- used to validate payloads when deserializing
-
JsonInstanceSerializer
CURATOR-275 introduced a new field intoServiceInstance. This caused a potentialUnrecognizedPropertyExceptionin older clients that read newly serialized ServiceInstances. If you are susceptible to this you should set the serializer to be an instance ofJsonInstanceSerializerwithcompatibleSerializationModeset to true. IMPORTANT: when this is done, the newenabledfield of ServiceInstance is not serialized. If however you do want to use theenabledfield, setcompatibleSerializationModeto false.- Parameters:
payloadClass- used to validate payloads when deserializingcompatibleSerializationMode- pass true to serialize in a manner that supports clients pre-CURATOR-275
-
-
Method Details
-
deserialize
Description copied from interface:InstanceSerializerDeserialize a byte array into an instance- Specified by:
deserializein interfaceInstanceSerializer<T>- Parameters:
bytes- the bytes- Returns:
- service instance
- Throws:
Exception- any errors
-
serialize
Description copied from interface:InstanceSerializerSerialize an instance into bytes- Specified by:
serializein interfaceInstanceSerializer<T>- Parameters:
instance- the instance- Returns:
- byte array representing the instance
- Throws:
Exception- any errors
-