Fixing ticket #450, lifeCycle = Permanent => boilerplate reduction
This commit is contained in:
parent
a21077707e
commit
ea5f21457a
27 changed files with 103 additions and 112 deletions
|
|
@ -91,16 +91,10 @@ object ActorSerialization {
|
|||
private[akka] def toSerializedActorRefProtocol[T <: Actor](
|
||||
actorRef: ActorRef, format: Format[T], serializeMailBox: Boolean = true): SerializedActorRefProtocol = {
|
||||
val lifeCycleProtocol: Option[LifeCycleProtocol] = {
|
||||
def setScope(builder: LifeCycleProtocol.Builder, scope: Scope) = scope match {
|
||||
case Permanent => builder.setLifeCycle(LifeCycleType.PERMANENT)
|
||||
case Temporary => builder.setLifeCycle(LifeCycleType.TEMPORARY)
|
||||
}
|
||||
val builder = LifeCycleProtocol.newBuilder
|
||||
actorRef.lifeCycle match {
|
||||
case Some(LifeCycle(scope)) =>
|
||||
setScope(builder, scope)
|
||||
Some(builder.build)
|
||||
case None => None
|
||||
case Permanent => Some(LifeCycleProtocol.newBuilder.setLifeCycle(LifeCycleType.PERMANENT).build)
|
||||
case Temporary => Some(LifeCycleProtocol.newBuilder.setLifeCycle(LifeCycleType.TEMPORARY).build)
|
||||
case UndefinedLifeCycle => None//No need to send the undefined lifecycle over the wire //builder.setLifeCycle(LifeCycleType.UNDEFINED)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -164,11 +158,12 @@ object ActorSerialization {
|
|||
|
||||
val lifeCycle =
|
||||
if (protocol.hasLifeCycle) {
|
||||
val lifeCycleProtocol = protocol.getLifeCycle
|
||||
Some(if (lifeCycleProtocol.getLifeCycle == LifeCycleType.PERMANENT) LifeCycle(Permanent)
|
||||
else if (lifeCycleProtocol.getLifeCycle == LifeCycleType.TEMPORARY) LifeCycle(Temporary)
|
||||
else throw new IllegalActorStateException("LifeCycle type is not valid: " + lifeCycleProtocol.getLifeCycle))
|
||||
} else None
|
||||
protocol.getLifeCycle.getLifeCycle match {
|
||||
case LifeCycleType.PERMANENT => Permanent
|
||||
case LifeCycleType.TEMPORARY => Temporary
|
||||
case unknown => throw new IllegalActorStateException("LifeCycle type is not valid: " + unknown)
|
||||
}
|
||||
} else UndefinedLifeCycle
|
||||
|
||||
val supervisor =
|
||||
if (protocol.hasSupervisor)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue