Problem: I have used the cake pattern to build a system of components (traits) which define a family of types and specialise them covariantly (cf., family polymorphism). Then I have defined a component which defines some actors and messages to be exchanged among these actors.
trait BasicTypes {
type T1 <: T1Interface
type T2 <: T2Interface
// other stuff
}
trait MyActors { self: BasicTypes =>
case class Msg1(v1: T1, v2: T2)
case class Msg2(name: String)
class MyActor { ... }
}
The problem is that the cake gets larger, possibly including non-serializable stuff. The result is a number of akka.remote.MessageSerializer$SerializationException
s.
Questions:
- Is there any way to fix this without flattening the design (i.e., while keeping the Cake pattern)?
- May I implement custom serialisation using
writeObject
andreadObject
for case classes? - How can I avoid the serialisation of the 'outer object' of my messages?