Package akka.serialization.jackson
Class JacksonMigration
- java.lang.Object
-
- akka.serialization.jackson.JacksonMigration
-
public abstract class JacksonMigration extends java.lang.Object
Data migration of old formats to current format can be implemented in a concrete subclass and configured to be used by theJacksonSerializer
for 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 int
currentVersion()
Define current version, that is, the value used when serializing new data.int
supportedForwardVersion()
Define the supported forward version this migration can read (must be greater or equal thancurrentVersion
).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.java.lang.String
transformClassName(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()
aJacksonMigration
may 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. TheJsonNode
is mutable so you can add and remove fields, or change values. Note that you have to cast to specific sub-classes such asObjectNode
andArrayNode
to 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.
-
-