* Copied from Lagom, with the following differences * Jsonable and CompressedJsonable not included * pcollection and guava modules not enabled by default * added scala and afterburner modules * JSON, CBOR and Smile options (different serializers) * JMH benchmark * jackson version 2.9.9 * test polymorphism * serializer for ActorRef * Address serializer * FiniteDuration serializer, same as java.time.Duration * use blacklist from Jackson databind against gadgets * disallow binding to open ended types, such as java.io.Serializable * Configurable ObjectMapper ser/deser features * testing date formats with WRITE_DATES_AS_TIMESTAMPS on/off * ActorSystemSetup for ObjectMapper creation * and possibility to lookup created ObjectMapper via ObjectMapperProvider extension * createObjectMapper without ActorSystem, needed by Lagom test * add basic docs * skip Scala 2.13 for akka-serialization-jackson for now, until the Jackson Scala module has been released
43 lines
1.1 KiB
Scala
43 lines
1.1 KiB
Scala
/*
|
|
* Copyright (C) 2019 Lightbend Inc. <https://www.lightbend.com>
|
|
*/
|
|
|
|
package doc.akka.serialization.jackson
|
|
|
|
//#marker-interface
|
|
/**
|
|
* Marker interface for messages, events and snapshots that are serialized with Jackson.
|
|
*/
|
|
trait MySerializable
|
|
|
|
final case class Message(name: String, nr: Int) extends MySerializable
|
|
//#marker-interface
|
|
|
|
object SerializationDocSpec {
|
|
val config = """
|
|
#//#serialization-bindings
|
|
akka.actor {
|
|
serialization-bindings {
|
|
"com.myservice.MySerializable" = jackson-json
|
|
}
|
|
}
|
|
#//#serialization-bindings
|
|
"""
|
|
|
|
val configMigration = """
|
|
#//#migrations-conf
|
|
akka.serialization.jackson.migrations {
|
|
"com.myservice.event.ItemAdded" = "com.myservice.event.ItemAddedMigration"
|
|
}
|
|
#//#migrations-conf
|
|
"""
|
|
|
|
val configMigrationRenamClass = """
|
|
#//#migrations-conf-rename
|
|
akka.serialization.jackson.migrations {
|
|
"com.myservice.event.OrederAdded" = "com.myservice.event.OrderPlacedMigration"
|
|
}
|
|
#//#migrations-conf-rename
|
|
"""
|
|
}
|
|
// FIXME add real tests for the migrations, see EventMigrationTest.java in Lagom
|