Fixing ticket #450, lifeCycle = Permanent => boilerplate reduction

This commit is contained in:
Viktor Klang 2010-10-04 11:18:10 +02:00
parent 099820a258
commit 3efb427ca1
27 changed files with 103 additions and 112 deletions

View file

@ -159,7 +159,7 @@ object Actor extends Logging {
*/ */
def actor(body: Receive): ActorRef = def actor(body: Receive): ActorRef =
actorOf(new Actor() { actorOf(new Actor() {
self.lifeCycle = Some(LifeCycle(Permanent)) self.lifeCycle = Permanent
def receive: Receive = body def receive: Receive = body
}).start }).start
@ -181,7 +181,7 @@ object Actor extends Logging {
*/ */
def transactor(body: Receive): ActorRef = def transactor(body: Receive): ActorRef =
actorOf(new Transactor() { actorOf(new Transactor() {
self.lifeCycle = Some(LifeCycle(Permanent)) self.lifeCycle = Permanent
def receive: Receive = body def receive: Receive = body
}).start }).start
@ -201,7 +201,7 @@ object Actor extends Logging {
*/ */
def temporaryActor(body: Receive): ActorRef = def temporaryActor(body: Receive): ActorRef =
actorOf(new Actor() { actorOf(new Actor() {
self.lifeCycle = Some(LifeCycle(Temporary)) self.lifeCycle = Temporary
def receive = body def receive = body
}).start }).start
@ -226,7 +226,7 @@ object Actor extends Logging {
def handler[A](body: => Unit) = new { def handler[A](body: => Unit) = new {
def receive(handler: Receive) = def receive(handler: Receive) =
actorOf(new Actor() { actorOf(new Actor() {
self.lifeCycle = Some(LifeCycle(Permanent)) self.lifeCycle = Permanent
body body
def receive = handler def receive = handler
}).start }).start

View file

@ -160,12 +160,6 @@ trait ActorRef extends ActorRefShared with TransactionManagement with Logging wi
def setFaultHandler(handler: FaultHandlingStrategy) = this.faultHandler = Some(handler) def setFaultHandler(handler: FaultHandlingStrategy) = this.faultHandler = Some(handler)
def getFaultHandler(): Option[FaultHandlingStrategy] = faultHandler def getFaultHandler(): Option[FaultHandlingStrategy] = faultHandler
/**
* Defines the life-cycle for a supervised actor.
*/
def setLifeCycle(lifeCycle: LifeCycle) = this.lifeCycle = Some(lifeCycle)
def getLifeCycle(): Option[LifeCycle] = lifeCycle
@volatile @volatile
private[akka] var _dispatcher: MessageDispatcher = Dispatchers.defaultGlobalDispatcher private[akka] var _dispatcher: MessageDispatcher = Dispatchers.defaultGlobalDispatcher
@ -698,7 +692,7 @@ class LocalActorRef private[akka] (
__isTransactor: Boolean, __isTransactor: Boolean,
__timeout: Long, __timeout: Long,
__receiveTimeout: Option[Long], __receiveTimeout: Option[Long],
__lifeCycle: Option[LifeCycle], __lifeCycle: LifeCycle,
__supervisor: Option[ActorRef], __supervisor: Option[ActorRef],
__hotswap: Option[PartialFunction[Any, Unit]], __hotswap: Option[PartialFunction[Any, Unit]],
__factory: () => Actor) = { __factory: () => Actor) = {
@ -1088,7 +1082,7 @@ class LocalActorRef private[akka] (
val failedActor = actorInstance.get val failedActor = actorInstance.get
guard.withGuard { guard.withGuard {
lifeCycle match { lifeCycle match {
case Some(LifeCycle(Temporary)) => shutDownTemporaryActor(this) case Temporary => shutDownTemporaryActor(this)
case _ => case _ =>
// either permanent or none where default is permanent // either permanent or none where default is permanent
Actor.log.info("Restarting actor [%s] configured as PERMANENT.", id) Actor.log.info("Restarting actor [%s] configured as PERMANENT.", id)
@ -1109,7 +1103,7 @@ class LocalActorRef private[akka] (
linkedActorsAsList.foreach { actorRef => linkedActorsAsList.foreach { actorRef =>
actorRef.lifeCycle match { actorRef.lifeCycle match {
// either permanent or none where default is permanent // either permanent or none where default is permanent
case Some(LifeCycle(Temporary)) => shutDownTemporaryActor(actorRef) case Temporary => shutDownTemporaryActor(actorRef)
case _ => actorRef.restart(reason, maxNrOfRetries, withinTimeRange) case _ => actorRef.restart(reason, maxNrOfRetries, withinTimeRange)
} }
} }
@ -1274,7 +1268,7 @@ class LocalActorRef private[akka] (
if (supervisor.isDefined) notifySupervisorWithMessage(Exit(this, reason)) if (supervisor.isDefined) notifySupervisorWithMessage(Exit(this, reason))
else { else {
lifeCycle match { lifeCycle match {
case Some(LifeCycle(Temporary)) => shutDownTemporaryActor(this) case Temporary => shutDownTemporaryActor(this)
case _ => case _ =>
} }
} }
@ -1495,7 +1489,8 @@ trait ScalaActorRef extends ActorRefShared { ref: ActorRef =>
* Defines the life-cycle for a supervised actor. * Defines the life-cycle for a supervised actor.
*/ */
@volatile @volatile
var lifeCycle: Option[LifeCycle] = None @BeanProperty
var lifeCycle: LifeCycle = UndefinedLifeCycle
/** /**
* User overridable callback/setting. * User overridable callback/setting.

View file

@ -29,10 +29,10 @@ class SupervisorException private[akka](message: String) extends AkkaException(m
* RestartStrategy(OneForOne, 3, 10, List(classOf[Exception]), * RestartStrategy(OneForOne, 3, 10, List(classOf[Exception]),
* Supervise( * Supervise(
* myFirstActor, * myFirstActor,
* LifeCycle(Permanent)) :: * Permanent) ::
* Supervise( * Supervise(
* mySecondActor, * mySecondActor,
* LifeCycle(Permanent)) :: * Permanent) ::
* Nil)) * Nil))
* </pre> * </pre>
* *
@ -60,10 +60,10 @@ object Supervisor {
* RestartStrategy(OneForOne, 3, 10, List(classOf[Exception]), * RestartStrategy(OneForOne, 3, 10, List(classOf[Exception]),
* Supervise( * Supervise(
* myFirstActor, * myFirstActor,
* LifeCycle(Permanent)) :: * Permanent) ::
* Supervise( * Supervise(
* mySecondActor, * mySecondActor,
* LifeCycle(Permanent)) :: * Permanent) ::
* Nil)) * Nil))
* </pre> * </pre>
* *
@ -160,7 +160,7 @@ sealed class Supervisor private[akka] (
else list else list
} }
_childActors.put(className, actorRef :: currentActors) _childActors.put(className, actorRef :: currentActors)
actorRef.lifeCycle = Some(lifeCycle) actorRef.lifeCycle = lifeCycle
supervisor.link(actorRef) supervisor.link(actorRef)
remoteAddress.foreach { address => remoteAddress.foreach { address =>
RemoteServerModule.registerActor( RemoteServerModule.registerActor(

View file

@ -32,12 +32,13 @@ object ScalaConfig {
abstract class Server extends ConfigElement abstract class Server extends ConfigElement
abstract class FailOverScheme extends ConfigElement abstract class FailOverScheme extends ConfigElement
abstract class Scope extends ConfigElement abstract class LifeCycle extends ConfigElement
case class SupervisorConfig(restartStrategy: RestartStrategy, worker: List[Server]) extends Server case class SupervisorConfig(restartStrategy: RestartStrategy, worker: List[Server]) extends Server
class Supervise(val actorRef: ActorRef, val lifeCycle: LifeCycle, _remoteAddress: RemoteAddress) extends Server { class Supervise(val actorRef: ActorRef, val lifeCycle: LifeCycle, _remoteAddress: RemoteAddress) extends Server {
val remoteAddress: Option[RemoteAddress] = if (_remoteAddress eq null) None else Some(_remoteAddress) val remoteAddress: Option[RemoteAddress] = if (_remoteAddress eq null) None else Some(_remoteAddress)
} }
object Supervise { object Supervise {
def apply(actorRef: ActorRef, lifeCycle: LifeCycle, remoteAddress: RemoteAddress) = new Supervise(actorRef, lifeCycle, remoteAddress) def apply(actorRef: ActorRef, lifeCycle: LifeCycle, remoteAddress: RemoteAddress) = new Supervise(actorRef, lifeCycle, remoteAddress)
def apply(actorRef: ActorRef, lifeCycle: LifeCycle) = new Supervise(actorRef, lifeCycle, null) def apply(actorRef: ActorRef, lifeCycle: LifeCycle) = new Supervise(actorRef, lifeCycle, null)
@ -53,9 +54,9 @@ object ScalaConfig {
case object AllForOne extends FailOverScheme case object AllForOne extends FailOverScheme
case object OneForOne extends FailOverScheme case object OneForOne extends FailOverScheme
case class LifeCycle(scope: Scope) extends ConfigElement case object Permanent extends LifeCycle
case object Permanent extends Scope case object Temporary extends LifeCycle
case object Temporary extends Scope case object UndefinedLifeCycle extends LifeCycle
case class RemoteAddress(val hostname: String, val port: Int) extends ConfigElement case class RemoteAddress(val hostname: String, val port: Int) extends ConfigElement
@ -139,22 +140,22 @@ object JavaConfig {
scheme.transform, maxNrOfRetries, withinTimeRange, trapExceptions.toList) scheme.transform, maxNrOfRetries, withinTimeRange, trapExceptions.toList)
} }
class LifeCycle(@BeanProperty val scope: Scope) extends ConfigElement { abstract class LifeCycle extends ConfigElement {
def transform = { def transform: se.scalablesolutions.akka.config.ScalaConfig.LifeCycle
se.scalablesolutions.akka.config.ScalaConfig.LifeCycle(scope.transform)
}
} }
abstract class Scope extends ConfigElement { class Permanent extends LifeCycle {
def transform: se.scalablesolutions.akka.config.ScalaConfig.Scope
}
class Permanent extends Scope {
override def transform = se.scalablesolutions.akka.config.ScalaConfig.Permanent override def transform = se.scalablesolutions.akka.config.ScalaConfig.Permanent
} }
class Temporary extends Scope {
class Temporary extends LifeCycle {
override def transform = se.scalablesolutions.akka.config.ScalaConfig.Temporary override def transform = se.scalablesolutions.akka.config.ScalaConfig.Temporary
} }
class UndefinedLifeCycle extends LifeCycle {
override def transform = se.scalablesolutions.akka.config.ScalaConfig.UndefinedLifeCycle
}
abstract class FailOverScheme extends ConfigElement { abstract class FailOverScheme extends ConfigElement {
def transform: se.scalablesolutions.akka.config.ScalaConfig.FailOverScheme def transform: se.scalablesolutions.akka.config.ScalaConfig.FailOverScheme
} }

View file

@ -20,7 +20,7 @@ object ActorFireForgetRequestReplySpec {
} }
class CrashingTemporaryActor extends Actor { class CrashingTemporaryActor extends Actor {
self.lifeCycle = Some(LifeCycle(Temporary)) self.lifeCycle = Temporary
def receive = { def receive = {
case "Die" => case "Die" =>

View file

@ -58,10 +58,10 @@ class SupervisorMiscSpec extends WordSpec with MustMatchers {
val sup = Supervisor( val sup = Supervisor(
SupervisorConfig( SupervisorConfig(
RestartStrategy(OneForOne, 3, 5000, List(classOf[Exception])), RestartStrategy(OneForOne, 3, 5000, List(classOf[Exception])),
Supervise(actor1, LifeCycle(Permanent)) :: Supervise(actor1, Permanent) ::
Supervise(actor2, LifeCycle(Permanent)) :: Supervise(actor2, Permanent) ::
Supervise(actor3, LifeCycle(Permanent)) :: Supervise(actor3, Permanent) ::
Supervise(actor4, LifeCycle(Permanent)) :: Supervise(actor4, Permanent) ::
Nil)) Nil))
actor1 ! "kill" actor1 ! "kill"

View file

@ -78,7 +78,7 @@ object SupervisorSpec {
class TemporaryActor extends Actor { class TemporaryActor extends Actor {
import self._ import self._
lifeCycle = Some(LifeCycle(Temporary)) lifeCycle = Temporary
def receive = { def receive = {
case Ping => case Ping =>
messageLog.put("ping") messageLog.put("ping")
@ -506,7 +506,7 @@ class SupervisorSpec extends JUnitSuite {
RestartStrategy(AllForOne, 3, 5000, List(classOf[Exception])), RestartStrategy(AllForOne, 3, 5000, List(classOf[Exception])),
Supervise( Supervise(
temporaryActor, temporaryActor,
LifeCycle(Temporary)) Temporary)
:: Nil)) :: Nil))
} }
@ -518,7 +518,7 @@ class SupervisorSpec extends JUnitSuite {
RestartStrategy(AllForOne, 3, 5000, List(classOf[Exception])), RestartStrategy(AllForOne, 3, 5000, List(classOf[Exception])),
Supervise( Supervise(
pingpong1, pingpong1,
LifeCycle(Permanent)) Permanent)
:: Nil)) :: Nil))
} }
@ -530,7 +530,7 @@ class SupervisorSpec extends JUnitSuite {
RestartStrategy(OneForOne, 3, 5000, List(classOf[Exception])), RestartStrategy(OneForOne, 3, 5000, List(classOf[Exception])),
Supervise( Supervise(
pingpong1, pingpong1,
LifeCycle(Permanent)) Permanent)
:: Nil)) :: Nil))
} }
@ -544,15 +544,15 @@ class SupervisorSpec extends JUnitSuite {
RestartStrategy(AllForOne, 3, 5000, List(classOf[Exception])), RestartStrategy(AllForOne, 3, 5000, List(classOf[Exception])),
Supervise( Supervise(
pingpong1, pingpong1,
LifeCycle(Permanent)) Permanent)
:: ::
Supervise( Supervise(
pingpong2, pingpong2,
LifeCycle(Permanent)) Permanent)
:: ::
Supervise( Supervise(
pingpong3, pingpong3,
LifeCycle(Permanent)) Permanent)
:: Nil)) :: Nil))
} }
@ -566,15 +566,15 @@ class SupervisorSpec extends JUnitSuite {
RestartStrategy(OneForOne, 3, 5000, List(classOf[Exception])), RestartStrategy(OneForOne, 3, 5000, List(classOf[Exception])),
Supervise( Supervise(
pingpong1, pingpong1,
LifeCycle(Permanent)) Permanent)
:: ::
Supervise( Supervise(
pingpong2, pingpong2,
LifeCycle(Permanent)) Permanent)
:: ::
Supervise( Supervise(
pingpong3, pingpong3,
LifeCycle(Permanent)) Permanent)
:: Nil)) :: Nil))
} }
@ -588,17 +588,17 @@ class SupervisorSpec extends JUnitSuite {
RestartStrategy(AllForOne, 3, 5000, List(classOf[Exception])), RestartStrategy(AllForOne, 3, 5000, List(classOf[Exception])),
Supervise( Supervise(
pingpong1, pingpong1,
LifeCycle(Permanent)) Permanent)
:: ::
SupervisorConfig( SupervisorConfig(
RestartStrategy(AllForOne, 3, 5000, Nil), RestartStrategy(AllForOne, 3, 5000, Nil),
Supervise( Supervise(
pingpong2, pingpong2,
LifeCycle(Permanent)) Permanent)
:: ::
Supervise( Supervise(
pingpong3, pingpong3,
LifeCycle(Permanent)) Permanent)
:: Nil) :: Nil)
:: Nil)) :: Nil))
} }

View file

@ -98,7 +98,7 @@ class SchedulerSpec extends JUnitSuite {
val pingLatch = new CountDownLatch(6) val pingLatch = new CountDownLatch(6)
val actor = actorOf(new Actor { val actor = actorOf(new Actor {
self.lifeCycle = Some(LifeCycle(Permanent)) self.lifeCycle = Permanent
def receive = { def receive = {
case Ping => pingLatch.countDown case Ping => pingLatch.countDown
@ -113,7 +113,7 @@ class SchedulerSpec extends JUnitSuite {
List(classOf[Exception])), List(classOf[Exception])),
Supervise( Supervise(
actor, actor,
LifeCycle(Permanent)) Permanent)
:: Nil)).start :: Nil)).start
Scheduler.schedule(actor, Ping, 500, 500, TimeUnit.MILLISECONDS) Scheduler.schedule(actor, Ping, 500, 500, TimeUnit.MILLISECONDS)

View file

@ -16,7 +16,7 @@ private[amqp] class FaultTolerantConnectionActor(connectionParameters: Connectio
import connectionParameters._ import connectionParameters._
self.id = "amqp-connection-%s".format(host) self.id = "amqp-connection-%s".format(host)
self.lifeCycle = Some(LifeCycle(Permanent)) self.lifeCycle = Permanent
self.trapExit = List(classOf[Throwable]) self.trapExit = List(classOf[Throwable])
self.faultHandler = Some(OneForOneStrategy(5, 5000)) self.faultHandler = Some(OneForOneStrategy(5, 5000))

View file

@ -36,7 +36,7 @@ case class VADD_WITH_SLICE(vsToAdd: List[String], start: Int, cnt: Int)
object Storage { object Storage {
class HbaseSampleMapStorage extends Actor { class HbaseSampleMapStorage extends Actor {
self.lifeCycle = Some(LifeCycle(Permanent)) self.lifeCycle = Permanent
val FOO_MAP = "akka.sample.map" val FOO_MAP = "akka.sample.map"
private var fooMap = atomic { HbaseStorage.getMap(FOO_MAP) } private var fooMap = atomic { HbaseStorage.getMap(FOO_MAP) }
@ -119,7 +119,7 @@ object Storage {
} }
class HbaseSampleVectorStorage extends Actor { class HbaseSampleVectorStorage extends Actor {
self.lifeCycle = Some(LifeCycle(Permanent)) self.lifeCycle = Permanent
val FOO_VECTOR = "akka.sample.vector" val FOO_VECTOR = "akka.sample.vector"
private var fooVector = atomic { HbaseStorage.getVector(FOO_VECTOR) } private var fooVector = atomic { HbaseStorage.getVector(FOO_VECTOR) }

View file

@ -36,7 +36,7 @@ case class VADD_WITH_SLICE(vsToAdd: List[String], start: Int, cnt: Int)
object Storage { object Storage {
class MongoSampleMapStorage extends Actor { class MongoSampleMapStorage extends Actor {
self.lifeCycle = Some(LifeCycle(Permanent)) self.lifeCycle = Permanent
val FOO_MAP = "akka.sample.map" val FOO_MAP = "akka.sample.map"
private var fooMap = atomic { MongoStorage.getMap(FOO_MAP) } private var fooMap = atomic { MongoStorage.getMap(FOO_MAP) }
@ -119,7 +119,7 @@ object Storage {
} }
class MongoSampleVectorStorage extends Actor { class MongoSampleVectorStorage extends Actor {
self.lifeCycle = Some(LifeCycle(Permanent)) self.lifeCycle = Permanent
val FOO_VECTOR = "akka.sample.vector" val FOO_VECTOR = "akka.sample.vector"
private var fooVector = atomic { MongoStorage.getVector(FOO_VECTOR) } private var fooVector = atomic { MongoStorage.getVector(FOO_VECTOR) }

View file

@ -28,7 +28,7 @@ case class SETFOO(s: String)
object SampleStorage { object SampleStorage {
class RedisSampleStorage extends Actor { class RedisSampleStorage extends Actor {
self.lifeCycle = Some(LifeCycle(Permanent)) self.lifeCycle = Permanent
val EVENT_MAP = "akka.sample.map" val EVENT_MAP = "akka.sample.map"
private var eventMap = atomic { RedisStorage.getMap(EVENT_MAP) } private var eventMap = atomic { RedisStorage.getMap(EVENT_MAP) }

View file

@ -41,7 +41,7 @@ case class VADD_WITH_SLICE(vsToAdd: List[String], start: Int, cnt: Int)
object Storage { object Storage {
class RedisSampleMapStorage extends Actor { class RedisSampleMapStorage extends Actor {
self.lifeCycle = Some(LifeCycle(Permanent)) self.lifeCycle = Permanent
val FOO_MAP = "akka.sample.map" val FOO_MAP = "akka.sample.map"
private var fooMap = atomic { RedisStorage.getMap(FOO_MAP) } private var fooMap = atomic { RedisStorage.getMap(FOO_MAP) }
@ -134,7 +134,7 @@ object Storage {
} }
class RedisSampleVectorStorage extends Actor { class RedisSampleVectorStorage extends Actor {
self.lifeCycle = Some(LifeCycle(Permanent)) self.lifeCycle = Permanent
val FOO_VECTOR = "akka.sample.vector" val FOO_VECTOR = "akka.sample.vector"
private var fooVector = atomic { RedisStorage.getVector(FOO_VECTOR) } private var fooVector = atomic { RedisStorage.getVector(FOO_VECTOR) }

View file

@ -241,7 +241,7 @@ object Cluster extends Cluster with Logging {
Some(Supervisor( Some(Supervisor(
SupervisorConfig( SupervisorConfig(
RestartStrategy(OneForOne, 5, 1000, List(classOf[Exception])), RestartStrategy(OneForOne, 5, 1000, List(classOf[Exception])),
Supervise(actor, LifeCycle(Permanent)) :: Nil))) Supervise(actor, Permanent) :: Nil)))
private[this] def clusterActor = if (clusterActorRef.isEmpty) None else Some(clusterActorRef.get.actor.asInstanceOf[ClusterActor]) private[this] def clusterActor = if (clusterActorRef.isEmpty) None else Some(clusterActorRef.get.actor.asInstanceOf[ClusterActor])

View file

@ -91,16 +91,10 @@ object ActorSerialization {
private[akka] def toSerializedActorRefProtocol[T <: Actor]( private[akka] def toSerializedActorRefProtocol[T <: Actor](
actorRef: ActorRef, format: Format[T], serializeMailBox: Boolean = true): SerializedActorRefProtocol = { actorRef: ActorRef, format: Format[T], serializeMailBox: Boolean = true): SerializedActorRefProtocol = {
val lifeCycleProtocol: Option[LifeCycleProtocol] = { 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 { actorRef.lifeCycle match {
case Some(LifeCycle(scope)) => case Permanent => Some(LifeCycleProtocol.newBuilder.setLifeCycle(LifeCycleType.PERMANENT).build)
setScope(builder, scope) case Temporary => Some(LifeCycleProtocol.newBuilder.setLifeCycle(LifeCycleType.TEMPORARY).build)
Some(builder.build) case UndefinedLifeCycle => None//No need to send the undefined lifecycle over the wire //builder.setLifeCycle(LifeCycleType.UNDEFINED)
case None => None
} }
} }
@ -164,11 +158,12 @@ object ActorSerialization {
val lifeCycle = val lifeCycle =
if (protocol.hasLifeCycle) { if (protocol.hasLifeCycle) {
val lifeCycleProtocol = protocol.getLifeCycle protocol.getLifeCycle.getLifeCycle match {
Some(if (lifeCycleProtocol.getLifeCycle == LifeCycleType.PERMANENT) LifeCycle(Permanent) case LifeCycleType.PERMANENT => Permanent
else if (lifeCycleProtocol.getLifeCycle == LifeCycleType.TEMPORARY) LifeCycle(Temporary) case LifeCycleType.TEMPORARY => Temporary
else throw new IllegalActorStateException("LifeCycle type is not valid: " + lifeCycleProtocol.getLifeCycle)) case unknown => throw new IllegalActorStateException("LifeCycle type is not valid: " + unknown)
} else None }
} else UndefinedLifeCycle
val supervisor = val supervisor =
if (protocol.hasSupervisor) if (protocol.hasSupervisor)

View file

@ -483,7 +483,7 @@ class RemoteSupervisorSpec extends JUnitSuite {
RestartStrategy(AllForOne, 3, 100, List(classOf[Exception])), RestartStrategy(AllForOne, 3, 100, List(classOf[Exception])),
Supervise( Supervise(
pingpong1, pingpong1,
LifeCycle(Permanent)) Permanent)
:: Nil)) :: Nil))
factory.newInstance factory.newInstance
@ -499,7 +499,7 @@ class RemoteSupervisorSpec extends JUnitSuite {
RestartStrategy(OneForOne, 3, 100, List(classOf[Exception])), RestartStrategy(OneForOne, 3, 100, List(classOf[Exception])),
Supervise( Supervise(
pingpong1, pingpong1,
LifeCycle(Permanent)) Permanent)
:: Nil)) :: Nil))
factory.newInstance factory.newInstance
} }
@ -520,15 +520,15 @@ class RemoteSupervisorSpec extends JUnitSuite {
RestartStrategy(AllForOne, 3, 100, List(classOf[Exception])), RestartStrategy(AllForOne, 3, 100, List(classOf[Exception])),
Supervise( Supervise(
pingpong1, pingpong1,
LifeCycle(Permanent)) Permanent)
:: ::
Supervise( Supervise(
pingpong2, pingpong2,
LifeCycle(Permanent)) Permanent)
:: ::
Supervise( Supervise(
pingpong3, pingpong3,
LifeCycle(Permanent)) Permanent)
:: Nil)) :: Nil))
factory.newInstance factory.newInstance
} }
@ -551,15 +551,15 @@ class RemoteSupervisorSpec extends JUnitSuite {
RestartStrategy(OneForOne, 3, 100, List(classOf[Exception])), RestartStrategy(OneForOne, 3, 100, List(classOf[Exception])),
Supervise( Supervise(
pingpong1, pingpong1,
LifeCycle(Permanent)) Permanent)
:: ::
Supervise( Supervise(
pingpong2, pingpong2,
LifeCycle(Permanent)) Permanent)
:: ::
Supervise( Supervise(
pingpong3, pingpong3,
LifeCycle(Permanent)) Permanent)
:: Nil)) :: Nil))
factory.newInstance factory.newInstance
} }
@ -580,17 +580,17 @@ class RemoteSupervisorSpec extends JUnitSuite {
RestartStrategy(AllForOne, 3, 100, List(classOf[Exception])), RestartStrategy(AllForOne, 3, 100, List(classOf[Exception])),
Supervise( Supervise(
pingpong1, pingpong1,
LifeCycle(Permanent)) Permanent)
:: ::
SupervisorConfig( SupervisorConfig(
RestartStrategy(AllForOne, 3, 100, List(classOf[Exception])), RestartStrategy(AllForOne, 3, 100, List(classOf[Exception])),
Supervise( Supervise(
pingpong2, pingpong2,
LifeCycle(Permanent)) Permanent)
:: ::
Supervise( Supervise(
pingpong3, pingpong3,
LifeCycle(Permanent)) Permanent)
:: Nil) :: Nil)
:: Nil)) :: Nil))
factory.newInstance factory.newInstance

View file

@ -55,13 +55,13 @@ class RemoteTypedActorSpec extends
new Component( new Component(
classOf[RemoteTypedActorOne], classOf[RemoteTypedActorOne],
classOf[RemoteTypedActorOneImpl], classOf[RemoteTypedActorOneImpl],
new LifeCycle(new Permanent), new Permanent,
10000, 10000,
new RemoteAddress("localhost", 9995)), new RemoteAddress("localhost", 9995)),
new Component( new Component(
classOf[RemoteTypedActorTwo], classOf[RemoteTypedActorTwo],
classOf[RemoteTypedActorTwoImpl], classOf[RemoteTypedActorTwoImpl],
new LifeCycle(new Permanent), new Permanent,
10000, 10000,
new RemoteAddress("localhost", 9995)) new RemoteAddress("localhost", 9995))
).toArray).supervise ).toArray).supervise

View file

@ -27,8 +27,8 @@ class Boot {
//val supervisor = Supervisor( //val supervisor = Supervisor(
// SupervisorConfig( // SupervisorConfig(
// RestartStrategy(OneForOne, 3, 100, List(classOf[Exception])), // RestartStrategy(OneForOne, 3, 100, List(classOf[Exception])),
// Supervise(actorOf[Consumer1], LifeCycle(Permanent)) :: // Supervise(actorOf[Consumer1], Permanent) ::
// Supervise(actorOf[Consumer2], LifeCycle(Permanent)) :: Nil)) // Supervise(actorOf[Consumer2], Permanent) :: Nil))
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Custom Camel route example // Custom Camel route example

View file

@ -97,7 +97,7 @@ trait ChatStorage extends Actor
* Redis-backed chat storage implementation. * Redis-backed chat storage implementation.
*/ */
class RedisChatStorage extends ChatStorage { class RedisChatStorage extends ChatStorage {
self.lifeCycle = Some(LifeCycle(Permanent)) self.lifeCycle = Permanent
val CHAT_LOG = "akka.chat.log" val CHAT_LOG = "akka.chat.log"
private var chatLog = atomic { RedisStorage.getVector(CHAT_LOG) } private var chatLog = atomic { RedisStorage.getVector(CHAT_LOG) }

View file

@ -16,12 +16,12 @@ public class Boot {
new Component( new Component(
SimpleService.class, SimpleService.class,
SimpleServiceImpl.class, SimpleServiceImpl.class,
new LifeCycle(new Permanent()), new Permanent(),
1000), 1000),
new Component( new Component(
PersistentSimpleService.class, PersistentSimpleService.class,
PersistentSimpleServiceImpl.class, PersistentSimpleServiceImpl.class,
new LifeCycle(new Permanent()), new Permanent(),
1000) 1000)
}).supervise(); }).supervise();
} }

View file

@ -28,13 +28,13 @@ class Boot {
RestartStrategy(OneForOne, 3, 100,List(classOf[Exception])), RestartStrategy(OneForOne, 3, 100,List(classOf[Exception])),
Supervise( Supervise(
actorOf[SimpleServiceActor], actorOf[SimpleServiceActor],
LifeCycle(Permanent)) :: Permanent) ::
Supervise( Supervise(
actorOf[ChatActor], actorOf[ChatActor],
LifeCycle(Permanent)) :: Permanent) ::
Supervise( Supervise(
actorOf[PersistentSimpleServiceActor], actorOf[PersistentSimpleServiceActor],
LifeCycle(Permanent)) Permanent)
:: Nil)) :: Nil))
factory.newInstance.start factory.newInstance.start
} }

View file

@ -20,18 +20,18 @@ class Boot {
// see akka.conf to enable one of these for the AkkaSecurityFilterFactory // see akka.conf to enable one of these for the AkkaSecurityFilterFactory
Supervise( Supervise(
actorOf[BasicAuthenticationService], actorOf[BasicAuthenticationService],
LifeCycle(Permanent)) :: Permanent) ::
/** /**
Supervise( Supervise(
actorOf[DigestAuthenticationService], actorOf[DigestAuthenticationService],
LifeCycle(Permanent)) :: Permanent) ::
Supervise( Supervise(
actorOf[SpnegoAuthenticationService], actorOf[SpnegoAuthenticationService],
LifeCycle(Permanent)) :: Permanent) ::
**/ **/
Supervise( Supervise(
actorOf[SecureTickActor], actorOf[SecureTickActor],
LifeCycle(Permanent)):: Nil)) Permanent):: Nil))
val supervisor = factory.newInstance val supervisor = factory.newInstance
supervisor.start supervisor.start

View file

@ -56,7 +56,7 @@ class SupervisionFactoryBean extends AbstractFactoryBean[AnyRef] {
*/ */
private[akka] def createComponent(props: ActorProperties): Component = { private[akka] def createComponent(props: ActorProperties): Component = {
import StringReflect._ import StringReflect._
val lifeCycle = if (!props.lifecycle.isEmpty && props.lifecycle.equalsIgnoreCase(VAL_LIFECYCYLE_TEMPORARY)) new LifeCycle(new Temporary()) else new LifeCycle(new Permanent()) val lifeCycle = if (!props.lifecycle.isEmpty && props.lifecycle.equalsIgnoreCase(VAL_LIFECYCYLE_TEMPORARY)) new Temporary() else new Permanent()
val isRemote = (props.host ne null) && (!props.host.isEmpty) val isRemote = (props.host ne null) && (!props.host.isEmpty)
val withInterface = (props.interface ne null) && (!props.interface.isEmpty) val withInterface = (props.interface ne null) && (!props.interface.isEmpty)
if (isRemote) { if (isRemote) {
@ -81,7 +81,7 @@ class SupervisionFactoryBean extends AbstractFactoryBean[AnyRef] {
*/ */
private[akka] def createSupervise(props: ActorProperties): Server = { private[akka] def createSupervise(props: ActorProperties): Server = {
import StringReflect._ import StringReflect._
val lifeCycle = if (!props.lifecycle.isEmpty && props.lifecycle.equalsIgnoreCase(VAL_LIFECYCYLE_TEMPORARY)) new LifeCycle(new Temporary()) else new LifeCycle(new Permanent()) val lifeCycle = if (!props.lifecycle.isEmpty && props.lifecycle.equalsIgnoreCase(VAL_LIFECYCYLE_TEMPORARY)) new Temporary() else new Permanent()
val isRemote = (props.host ne null) && (!props.host.isEmpty) val isRemote = (props.host ne null) && (!props.host.isEmpty)
val actorRef = Actor.actorOf(props.target.toClass) val actorRef = Actor.actorOf(props.target.toClass)
if (props.timeout > 0) { if (props.timeout > 0) {

View file

@ -33,13 +33,13 @@ class RestartNestedTransactionalTypedActorSpec extends
new RestartStrategy(new AllForOne, 3, 5000, List(classOf[Exception]).toArray), new RestartStrategy(new AllForOne, 3, 5000, List(classOf[Exception]).toArray),
List( List(
new Component(classOf[TransactionalTypedActor], new Component(classOf[TransactionalTypedActor],
new LifeCycle(new Permanent), new Permanent,
10000), 10000),
new Component(classOf[NestedTransactionalTypedActor], new Component(classOf[NestedTransactionalTypedActor],
new LifeCycle(new Permanent), new Permanent,
10000), 10000),
new Component(classOf[TypedActorFailer], new Component(classOf[TypedActorFailer],
new LifeCycle(new Permanent), new Permanent,
10000) 10000)
).toArray).supervise ).toArray).supervise
*/ */

View file

@ -33,11 +33,11 @@ class RestartTransactionalTypedActorSpec extends
List( List(
new Component( new Component(
classOf[TransactionalTypedActor], classOf[TransactionalTypedActor],
new LifeCycle(new Temporary), new Temporary,
10000), 10000),
new Component( new Component(
classOf[TypedActorFailer], classOf[TypedActorFailer],
new LifeCycle(new Temporary), new Temporary,
10000) 10000)
).toArray).supervise ).toArray).supervise
} }

View file

@ -41,13 +41,13 @@ class TypedActorGuiceConfiguratorSpec extends
new Component( new Component(
classOf[Foo], classOf[Foo],
classOf[FooImpl], classOf[FooImpl],
new LifeCycle(new Permanent), new Permanent,
1000, 1000,
dispatcher), dispatcher),
new Component( new Component(
classOf[Bar], classOf[Bar],
classOf[BarImpl], classOf[BarImpl],
new LifeCycle(new Permanent), new Permanent,
1000, 1000,
dispatcher) dispatcher)
).toArray).inject.supervise ).toArray).inject.supervise

View file

@ -22,8 +22,8 @@ class TypedActorLifecycleSpec extends Spec with ShouldMatchers with BeforeAndAft
override protected def beforeAll() = { override protected def beforeAll() = {
val strategy = new RestartStrategy(new AllForOne(), 3, 1000, Array(classOf[Exception])) val strategy = new RestartStrategy(new AllForOne(), 3, 1000, Array(classOf[Exception]))
val comp3 = new Component(classOf[SamplePojo], classOf[SamplePojoImpl], new LifeCycle(new Permanent()), 1000) val comp3 = new Component(classOf[SamplePojo], classOf[SamplePojoImpl], new Permanent(), 1000)
val comp4 = new Component(classOf[SamplePojo], classOf[SamplePojoImpl], new LifeCycle(new Temporary()), 1000) val comp4 = new Component(classOf[SamplePojo], classOf[SamplePojoImpl], new Temporary(), 1000)
conf1 = new TypedActorConfigurator().configure(strategy, Array(comp3)).supervise conf1 = new TypedActorConfigurator().configure(strategy, Array(comp3)).supervise
conf2 = new TypedActorConfigurator().configure(strategy, Array(comp4)).supervise conf2 = new TypedActorConfigurator().configure(strategy, Array(comp4)).supervise
} }