abstract class CirceAkkaSerializer[Ser <: AnyRef] extends SerializerWithStringManifest with AkkaCodecs
An abstract class that is extended to create a custom serializer.
After creating your subclass, don't forget to add your serializer and base trait to application.conf
(for more info https://doc.akka.io/docs/akka/2.5.32//serialization.html)
Example subclass:
class CustomSerializer(actorSystem: ExtendedActorSystem) extends CirceAkkaSerializer[MySerializable](actorSystem) { implicit private val serializabilityCodec: Codec[MySerializable] = genericCodec override def identifier: Int = 41 override lazy val codecs = Seq( Register[SthCommand], Register(implicitly[ru.TypeTag[ModifiedCodec]], prepareEncoder, prepareDecoder), Register[GenericClass[MySerializable, MySerializable]]) override lazy val manifestMigrations = Seq("app.OldName" -> classOf[TopTraitMigration]) override lazy val packagePrefix = "app" }
- Ser
base trait that is used to mark serialization
- Alphabetic
- By Inheritance
- CirceAkkaSerializer
- AkkaCodecs
- SerializerWithStringManifest
- Serializer
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
-
new
CirceAkkaSerializer(system: ExtendedActorSystem)(implicit arg0: ClassTag[Ser])
- system
ExtendedActorSystem that is provided by Akka
Abstract Value Members
-
abstract
val
codecs: Seq[Registration[_ <: Ser]]
Sequence that must contain org.virtuslab.ash.circe.Registration for all direct subclasses of Ser.
Sequence that must contain org.virtuslab.ash.circe.Registration for all direct subclasses of Ser.
Each
Registrationis created using org.virtuslab.ash.circe.Registers org.virtuslab.ash.circe.Register#apply method.To check if all needed classes are registered, use Codec Registration Checker.
- See also
org.virtuslab.ash.circe.Registerorg.virtuslab.ash.circe.Register#apply for more information about type derivation
-
abstract
def
identifier: Int
- Definition Classes
- SerializerWithStringManifest → Serializer
-
abstract
val
manifestMigrations: Seq[(String, Class[_])]
A sequence containing information used in type migration.
A sequence containing information used in type migration.
If you ever change the name of a class that is a direct descendant of
Serand is persisted in any way, you must append new pair to this field.- The first element of the pair is a String with the value of old FQCN.
- The second element of the pair is a class that had its name changed
Example:
override lazy val manifestMigrations = Seq( "app.OldName" -> classOf[app.NewName] )
-
abstract
val
packagePrefix: String
Package prefix of your project.
Package prefix of your project. Ensure that
Seris included in that package and as many classes that extend it.It should look something like
"org.group.project"It is used for some runtime checks that are executed near the end of initialisation by Akka.
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
implicit
def
actorRefCodec[T](implicit system: ActorSystem = serializationSystem): Codec[ActorRef[T]]
- Definition Classes
- AkkaCodecs
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
fromBinary(bytes: Array[Byte], manifest: String): AnyRef
- Definition Classes
- CirceAkkaSerializer → SerializerWithStringManifest
-
final
def
fromBinary(bytes: Array[Byte], manifest: Option[Class[_]]): AnyRef
- Definition Classes
- SerializerWithStringManifest → Serializer
-
final
def
fromBinary(bytes: Array[Byte], clazz: Class[_]): AnyRef
- Definition Classes
- Serializer
- Annotations
- @throws( ... )
-
final
def
fromBinary(bytes: Array[Byte]): AnyRef
- Definition Classes
- Serializer
-
def
genericCodec: Codec[Ser]
The intended usage of this method is to provide any form of support for generic classes.
The intended usage of this method is to provide any form of support for generic classes.
Because of type erasure, it's impossible to org.virtuslab.ash.circe.Register one generic class two times with different type parameters.
The trick for combating type erasure is to register generic class only once with type parameter being its upper bound, and provide custom made io.circe.Codec that can serialize/deserialize all classes that are used as a type parameter.
For example, if the upper bound is
Any, but you know that onlyIntandStringare used as a type parameter, then you can create a custom io.circe.Codec forAnythat handlesIntandStringand throwsExceptionotherwise.To use this method correctly, set the upper bound for the type parameter of generic class to
Serand put the returned Codec as implicit in a place that can be seen by type derivation.Example of generic class:
case class GenericClass[A <: MySerializable, B <: MySerializable](a: A, b: B) extends MySerializable
and its registration in serializer:
Register[GenericClass[MySerializable, MySerializable]]
- returns
io.circe.Codec that can serialize all subtypes of
Ser
- Attributes
- protected
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
includeManifest: Boolean
- Definition Classes
- SerializerWithStringManifest → Serializer
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
manifest(o: AnyRef): String
- Definition Classes
- CirceAkkaSerializer → SerializerWithStringManifest
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
implicit
def
sinkRefCodec[T](implicit system: ActorSystem = serializationSystem): Codec[SinkRef[T]]
- Definition Classes
- AkkaCodecs
-
implicit
def
sourceRefCodec[T](implicit system: ActorSystem = serializationSystem): Codec[SourceRef[T]]
- Definition Classes
- AkkaCodecs
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toBinary(o: AnyRef): Array[Byte]
- Definition Classes
- CirceAkkaSerializer → SerializerWithStringManifest → Serializer
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()