Package akka.serialization.jackson
Class JacksonMigration
- java.lang.Object
-
- akka.serialization.jackson.JacksonMigration
-
public abstract class JacksonMigration extends java.lang.ObjectData migration of old formats to current format can be implemented in a concrete subclass and configured to be used by theJacksonSerializerfor a changed class.It is used when deserializing data of older version than the
currentVersion(). You implement the transformation of the JSON structure in thetransform(int, com.fasterxml.jackson.databind.JsonNode)method. If you have changed the class name you should overridetransformClassName(int, java.lang.String)and return current class name.
-
-
Constructor Summary
Constructors Constructor Description JacksonMigration()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract intcurrentVersion()Define current version, that is, the value used when serializing new data.intsupportedForwardVersion()Define the supported forward version this migration can read (must be greater or equal thancurrentVersion).abstract com.fasterxml.jackson.databind.JsonNodetransform(int fromVersion, com.fasterxml.jackson.databind.JsonNode json)Implement the transformation of the old JSON structure to the new JSON structure.java.lang.StringtransformClassName(int fromVersion, java.lang.String className)Override this method if you have changed the class name.
-
-
-
Method Detail
-
currentVersion
public abstract int currentVersion()
Define current version, that is, the value used when serializing new data. The first version, when no migration was used, is always 1.
-
supportedForwardVersion
public int supportedForwardVersion()
Define the supported forward version this migration can read (must be greater or equal thancurrentVersion). If this value is different fromcurrentVersion()aJacksonMigrationmay be required to downcast the received payload to the current schema.
-
transform
public abstract com.fasterxml.jackson.databind.JsonNode transform(int fromVersion, com.fasterxml.jackson.databind.JsonNode json)Implement the transformation of the old JSON structure to the new JSON structure. TheJsonNodeis mutable so you can add and remove fields, or change values. Note that you have to cast to specific sub-classes such asObjectNodeandArrayNodeto get access to mutators.- Parameters:
fromVersion- the version of the old datajson- the old JSON data
-
transformClassName
public java.lang.String transformClassName(int fromVersion, java.lang.String className)Override this method if you have changed the class name. Return current class name.
-
-