Created
November 6, 2012 17:24
-
-
Save anonymous/4026158 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ActorRefSerializer(val system: ExtendedActorSystem) extends kryo.Serializer[ActorRef] { | |
override def read(kryo: Kryo, input: Input, typ: Class[ActorRef]): ActorRef = { | |
val path = input.readString() | |
system.actorFor(path) | |
} | |
override def write(kryo: Kryo, output: Output, obj: ActorRef) = { | |
Serialization.currentTransportAddress.value match { | |
case null => output.writeString(obj.path.toString) | |
case addr => output.writeString(obj.path.toStringWithAddress(addr)) | |
} | |
} | |
} | |
////////////// | |
// And then inside getKryo... | |
kryo.addDefaultSerializer(classOf[ActorRef], new ActorRefSerializer(system)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment