Imrovements from feedback. See #1755

This commit is contained in:
Patrik Nordwall 2012-05-15 17:16:46 +02:00
parent 6dd017d6c1
commit 793af8b4ec
3 changed files with 12 additions and 2 deletions

View file

@ -11,6 +11,11 @@ import akka.actor.ActorSystem
import akka.actor.ActorRef
object ProtobufSerializer {
/**
* Helper to serialize an [[akka.actor.ActorRef]] to Akka's
* protobuf representation.
*/
def serializeActorRef(ref: ActorRef): ActorRefProtocol = {
val identifier: String = Serialization.currentTransportAddress.value match {
case null ref.path.toString
@ -19,6 +24,11 @@ object ProtobufSerializer {
ActorRefProtocol.newBuilder.setPath(identifier).build
}
/**
* Helper to materialize (lookup) an [[akka.actor.ActorRef]]
* from Akka's protobuf representation in the supplied
* [[akka.actor.ActorSystem].
*/
def deserializeActorRef(system: ActorSystem, refProtocol: ActorRefProtocol): ActorRef =
system.actorFor(refProtocol.getPath)
}