diff --git a/akka-actor-tests/src/test/java/akka/config/SupervisionConfig.java b/akka-actor-tests/src/test/java/akka/config/SupervisionConfig.java deleted file mode 100644 index 97605a4a79..0000000000 --- a/akka-actor-tests/src/test/java/akka/config/SupervisionConfig.java +++ /dev/null @@ -1,23 +0,0 @@ -package akka.config; - -import akka.actor.*; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import static akka.config.Supervision.*; - -public class SupervisionConfig { - /*Just some sample code to demonstrate the declarative supervision configuration for Java */ - @SuppressWarnings("unchecked") - public SupervisorConfig createSupervisorConfig(List toSupervise) { - ArrayList targets = new ArrayList(toSupervise.size()); - for(ActorRef ref : toSupervise) { - targets.add(new Supervise(ref, permanent(), true)); - } - - - return new SupervisorConfig(new AllForOneStrategy(new Class[] { Exception.class }, 50, 1000), targets.toArray(new Server[targets.size()])); - } -} diff --git a/akka-actor-tests/src/test/scala/akka/actor/ActorFireForgetRequestReplySpec.scala b/akka-actor-tests/src/test/scala/akka/actor/ActorFireForgetRequestReplySpec.scala index f27c2c32b1..9af4e85e6f 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/ActorFireForgetRequestReplySpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/ActorFireForgetRequestReplySpec.scala @@ -12,8 +12,7 @@ import akka.testkit._ import akka.testkit.Testing.sleepFor import akka.util.duration._ -import Actor._ -import akka.config.Supervision._ +import akka.actor.Actor._ import akka.dispatch.Dispatchers object ActorFireForgetRequestReplySpec { @@ -84,7 +83,7 @@ class ActorFireForgetRequestReplySpec extends WordSpec with MustMatchers with Be "should shutdown crashed temporary actor" in { filterEvents(EventFilter[Exception]("Expected")) { - val supervisor = actorOf(Props(self ⇒ { case _ ⇒ }).withFaultHandler(OneForOneStrategy(List(classOf[Exception]), Some(0)))) + val supervisor = Supervisor(OneForOneStrategy(List(classOf[Exception]), Some(0))) val actor = actorOf(Props[CrashingActor].withSupervisor(supervisor)) actor.isRunning must be(true) actor ! "Die" diff --git a/akka-actor-tests/src/test/scala/akka/actor/FSMTransitionSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/FSMTransitionSpec.scala index 3d1fb82615..a59b86d425 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/FSMTransitionSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/FSMTransitionSpec.scala @@ -9,7 +9,6 @@ import org.scalatest.matchers.MustMatchers import akka.testkit._ import akka.testkit._ import akka.util.duration._ -import akka.config.Supervision._ import akka.event.EventHandler import FSM._ diff --git a/akka-actor-tests/src/test/scala/akka/actor/LoggingReceiveSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/LoggingReceiveSpec.scala index f073c84aa2..acf44573c1 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/LoggingReceiveSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/LoggingReceiveSpec.scala @@ -10,7 +10,6 @@ import akka.event.EventHandler import Actor._ import akka.util.duration._ import akka.config.Config.config -import akka.config.Supervision._ object LoggingReceiveSpec { class TestLogActor extends Actor { diff --git a/akka-actor-tests/src/test/scala/akka/actor/SchedulerSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/SchedulerSpec.scala index 52eeecb6d0..89bc8728db 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/SchedulerSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/SchedulerSpec.scala @@ -6,7 +6,6 @@ import akka.event.EventHandler import akka.testkit.TestEvent._ import akka.testkit.EventFilter import Actor._ -import akka.config.Supervision._ import org.multiverse.api.latches.StandardLatch import org.junit.{ Test, Before, After } import java.util.concurrent.{ ScheduledFuture, ConcurrentLinkedQueue, CountDownLatch, TimeUnit } diff --git a/akka-actor-tests/src/test/scala/akka/actor/SupervisorMiscSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/SupervisorMiscSpec.scala index 5631b84a58..ad6fc37e2b 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/SupervisorMiscSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/SupervisorMiscSpec.scala @@ -5,7 +5,6 @@ package akka.actor import org.scalatest.WordSpec import org.scalatest.matchers.MustMatchers -import akka.config.Supervision.{ SupervisorConfig, Supervise, Permanent } import akka.testkit.{ filterEvents, EventFilter } import akka.dispatch.{ PinnedDispatcher, Dispatchers } import java.util.concurrent.{ TimeUnit, CountDownLatch } diff --git a/akka-actor-tests/src/test/scala/akka/actor/SupervisorSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/SupervisorSpec.scala index 6b434ad21e..fc29ad35c7 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/SupervisorSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/SupervisorSpec.scala @@ -11,9 +11,8 @@ import org.scalatest.BeforeAndAfterAll import akka.testkit.Testing.sleepFor import akka.util.duration._ -import akka.config.Supervision._ import akka.{ Die, Ping } -import Actor._ +import akka.actor.Actor._ import akka.event.EventHandler import akka.testkit.TestEvent._ import akka.testkit.EventFilter @@ -70,120 +69,53 @@ object SupervisorSpec { // ===================================================== def temporaryActorAllForOne = { - val temporaryActor = actorOf(Props[PingPongActor]) - - val supervisor = Supervisor( - SupervisorConfig( - AllForOneStrategy(List(classOf[Exception]), Some(0)), - Supervise( - temporaryActor, - Temporary) - :: Nil)) + val supervisor = Supervisor(AllForOneStrategy(List(classOf[Exception]), Some(0))) + val temporaryActor = actorOf(Props[PingPongActor].withSupervisor(supervisor)) (temporaryActor, supervisor) } def singleActorAllForOne = { - val pingpong = actorOf[PingPongActor] - - val supervisor = Supervisor( - SupervisorConfig( - AllForOneStrategy(List(classOf[Exception]), 3, TimeoutMillis), - Supervise( - pingpong, - Permanent) - :: Nil)) + val supervisor = Supervisor(AllForOneStrategy(List(classOf[Exception]), 3, TimeoutMillis)) + val pingpong = actorOf(Props[PingPongActor].withSupervisor(supervisor)) (pingpong, supervisor) } def singleActorOneForOne = { - val pingpong = actorOf[PingPongActor] - - val supervisor = Supervisor( - SupervisorConfig( - OneForOneStrategy(List(classOf[Exception]), 3, TimeoutMillis), - Supervise( - pingpong, - Permanent) - :: Nil)) + val supervisor = Supervisor(OneForOneStrategy(List(classOf[Exception]), 3, TimeoutMillis)) + val pingpong = actorOf(Props[PingPongActor].withSupervisor(supervisor)) (pingpong, supervisor) } def multipleActorsAllForOne = { - val pingpong1 = actorOf[PingPongActor] - val pingpong2 = actorOf[PingPongActor] - val pingpong3 = actorOf[PingPongActor] - - val supervisor = Supervisor( - SupervisorConfig( - AllForOneStrategy(List(classOf[Exception]), 3, TimeoutMillis), - Supervise( - pingpong1, - Permanent) - :: - Supervise( - pingpong2, - Permanent) - :: - Supervise( - pingpong3, - Permanent) - :: Nil)) + val supervisor = Supervisor(AllForOneStrategy(List(classOf[Exception]), 3, TimeoutMillis)) + val pingpong1 = actorOf(Props[PingPongActor].withSupervisor(supervisor)) + val pingpong2 = actorOf(Props[PingPongActor].withSupervisor(supervisor)) + val pingpong3 = actorOf(Props[PingPongActor].withSupervisor(supervisor)) (pingpong1, pingpong2, pingpong3, supervisor) } def multipleActorsOneForOne = { - val pingpong1 = actorOf[PingPongActor] - val pingpong2 = actorOf[PingPongActor] - val pingpong3 = actorOf[PingPongActor] - - val supervisor = Supervisor( - SupervisorConfig( - OneForOneStrategy(List(classOf[Exception]), 3, TimeoutMillis), - Supervise( - pingpong1, - Permanent) - :: - Supervise( - pingpong2, - Permanent) - :: - Supervise( - pingpong3, - Permanent) - :: Nil)) + val supervisor = Supervisor(OneForOneStrategy(List(classOf[Exception]), 3, TimeoutMillis)) + val pingpong1 = actorOf(Props[PingPongActor].withSupervisor(supervisor)) + val pingpong2 = actorOf(Props[PingPongActor].withSupervisor(supervisor)) + val pingpong3 = actorOf(Props[PingPongActor].withSupervisor(supervisor)) (pingpong1, pingpong2, pingpong3, supervisor) } def nestedSupervisorsAllForOne = { - val pingpong1 = actorOf[PingPongActor] - val pingpong2 = actorOf[PingPongActor] - val pingpong3 = actorOf[PingPongActor] + val topSupervisor = Supervisor(AllForOneStrategy(List(classOf[Exception]), 3, TimeoutMillis)) + val pingpong1 = actorOf(Props[PingPongActor].withSupervisor(topSupervisor)) - val supervisor = Supervisor( - SupervisorConfig( - AllForOneStrategy(List(classOf[Exception]), 3, TimeoutMillis), - Supervise( - pingpong1, - Permanent) - :: - SupervisorConfig( - AllForOneStrategy(Nil, 3, TimeoutMillis), - Supervise( - pingpong2, - Permanent) - :: - Supervise( - pingpong3, - Permanent) - :: Nil) - :: Nil)) + val middleSupervisor = Supervisor(AllForOneStrategy(Nil, 3, TimeoutMillis), topSupervisor) + val pingpong2 = actorOf(Props[PingPongActor].withSupervisor(middleSupervisor)) + val pingpong3 = actorOf(Props[PingPongActor].withSupervisor(middleSupervisor)) - (pingpong1, pingpong2, pingpong3, supervisor) + (pingpong1, pingpong2, pingpong3, topSupervisor) } } @@ -359,6 +291,7 @@ class SupervisorSpec extends WordSpec with MustMatchers with BeforeAndAfterEach "must attempt restart when exception during restart" in { val inits = new AtomicInteger(0) + val supervisor = Supervisor(OneForOneStrategy(classOf[Exception] :: Nil, 3, 10000)) val dyingActor = actorOf(Props(new Actor { inits.incrementAndGet @@ -369,13 +302,7 @@ class SupervisorSpec extends WordSpec with MustMatchers with BeforeAndAfterEach case Ping ⇒ tryReply(PongMessage) case Die ⇒ throw new RuntimeException("Expected") } - })) - - val supervisor = - Supervisor( - SupervisorConfig( - OneForOneStrategy(classOf[Exception] :: Nil, 3, 10000), - Supervise(dyingActor, Permanent) :: Nil)) + }).withSupervisor(supervisor)) intercept[RuntimeException] { (dyingActor.?(Die, TimeoutMillis)).get @@ -388,7 +315,7 @@ class SupervisorSpec extends WordSpec with MustMatchers with BeforeAndAfterEach inits.get must be(3) - supervisor.shutdown() + supervisor.stop() } } } diff --git a/akka-actor-tests/src/test/scala/akka/actor/SupervisorTreeSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/SupervisorTreeSpec.scala index cfcb82c171..b42f302b96 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/SupervisorTreeSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/SupervisorTreeSpec.scala @@ -10,8 +10,7 @@ import akka.util.duration._ import akka.testkit.Testing.sleepFor import akka.testkit.{ EventFilter, filterEvents, filterException } import akka.dispatch.Dispatchers -import akka.config.Supervision.{ SupervisorConfig, Supervise, Permanent } -import Actor._ +import akka.actor.Actor._ class SupervisorTreeSpec extends WordSpec with MustMatchers { diff --git a/akka-actor-tests/src/test/scala/akka/actor/Ticket669Spec.scala b/akka-actor-tests/src/test/scala/akka/actor/Ticket669Spec.scala index 11ea8ff66b..4f16c1ec03 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/Ticket669Spec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/Ticket669Spec.scala @@ -6,12 +6,11 @@ package akka.actor import java.util.concurrent.{ CountDownLatch, TimeUnit } import akka.actor._ -import akka.config.Supervision._ -import akka.testkit.{ filterEvents, EventFilter } import org.scalatest.{ BeforeAndAfterAll, WordSpec } import org.scalatest.matchers.MustMatchers +import akka.testkit.{ TestKit, filterEvents, EventFilter } -class Ticket669Spec extends WordSpec with MustMatchers with BeforeAndAfterAll { +class Ticket669Spec extends WordSpec with MustMatchers with BeforeAndAfterAll with TestKit { import Ticket669Spec._ override def beforeAll = Thread.interrupted() //remove interrupted status. @@ -24,42 +23,29 @@ class Ticket669Spec extends WordSpec with MustMatchers with BeforeAndAfterAll { "A supervised actor with lifecycle PERMANENT" should { "be able to reply on failure during preRestart" in { filterEvents(EventFilter[Exception]("test")) { - val latch = new CountDownLatch(1) - val sender = Actor.actorOf(new Sender(latch)) - val supervisor = Actor.actorOf(Props(context ⇒ { case _ ⇒ }). - withFaultHandler(AllForOneStrategy(List(classOf[Exception]), 5, 10000))) + val supervisor = Supervisor(AllForOneStrategy(List(classOf[Exception]), 5, 10000)) val supervised = Actor.actorOf(Props[Supervised].withSupervisor(supervisor)) - supervised.!("test")(Some(sender)) - latch.await(5, TimeUnit.SECONDS) must be(true) + supervised.!("test")(Some(testActor)) + expectMsg("failure1") + supervisor.stop() } } "be able to reply on failure during postStop" in { filterEvents(EventFilter[Exception]("test")) { - val latch = new CountDownLatch(1) - val sender = Actor.actorOf(new Sender(latch)) - - val supervisor = Actor.actorOf(Props(context ⇒ { case _ ⇒ }). - withFaultHandler(AllForOneStrategy(List(classOf[Exception]), Some(0), None))) + val supervisor = Supervisor(AllForOneStrategy(List(classOf[Exception]), Some(0), None)) val supervised = Actor.actorOf(Props[Supervised].withSupervisor(supervisor)) - supervised.!("test")(Some(sender)) - latch.await(5, TimeUnit.SECONDS) must be(true) + supervised.!("test")(Some(testActor)) + expectMsg("failure2") + supervisor.stop() } } } } object Ticket669Spec { - class Sender(latch: CountDownLatch) extends Actor { - def receive = { - case "failure1" ⇒ latch.countDown() - case "failure2" ⇒ latch.countDown() - case _ ⇒ {} - } - } - class Supervised extends Actor { def receive = { case msg ⇒ throw new Exception("test") diff --git a/akka-actor-tests/src/test/scala/akka/routing/ActorPoolSpec.scala b/akka-actor-tests/src/test/scala/akka/routing/ActorPoolSpec.scala index e5b4d5bf60..43248224c2 100644 --- a/akka-actor-tests/src/test/scala/akka/routing/ActorPoolSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/routing/ActorPoolSpec.scala @@ -361,7 +361,6 @@ class ActorPoolSpec extends WordSpec with MustMatchers { "provide default supervision of pooled actors" in { filterException[RuntimeException] { - import akka.config.Supervision._ val pingCount = new AtomicInteger(0) val deathCount = new AtomicInteger(0) val keepDying = new AtomicBoolean(false) @@ -507,7 +506,6 @@ class ActorPoolSpec extends WordSpec with MustMatchers { "support customizable supervision config of pooled actors" in { filterEvents(EventFilter[IllegalStateException], EventFilter[RuntimeException]) { - import akka.config.Supervision._ val pingCount = new AtomicInteger(0) val deathCount = new AtomicInteger(0) var keepDying = new AtomicBoolean(false) diff --git a/akka-actor/src/main/scala/akka/actor/ActorRef.scala b/akka-actor/src/main/scala/akka/actor/ActorRef.scala index 683e42511c..3b8fd0dc8d 100644 --- a/akka-actor/src/main/scala/akka/actor/ActorRef.scala +++ b/akka-actor/src/main/scala/akka/actor/ActorRef.scala @@ -5,7 +5,6 @@ package akka.actor import akka.dispatch._ -import akka.config.Supervision._ import akka.util._ import akka.serialization.{ Serializer, Serialization } import ReflectiveAccess._ diff --git a/akka-actor/src/main/scala/akka/actor/Supervisor.scala b/akka-actor/src/main/scala/akka/actor/Supervisor.scala index 5559cbc43d..a34a2d4f65 100644 --- a/akka-actor/src/main/scala/akka/actor/Supervisor.scala +++ b/akka-actor/src/main/scala/akka/actor/Supervisor.scala @@ -4,180 +4,17 @@ package akka.actor -import akka.AkkaException -import akka.util._ -import ReflectiveAccess._ -import Actor._ -import java.util.concurrent.{ CopyOnWriteArrayList } -import akka.config.Supervision._ -import collection.mutable.ListBuffer - -class SupervisorException private[akka] (message: String, cause: Throwable = null) extends AkkaException(message, cause) { - def this(msg: String) = this(msg, null); -} - -/** - * Factory object for creating supervisors declarative. It creates instances of the 'Supervisor' class. - * These are not actors, if you need a supervisor that is an Actor then you have to use the 'SupervisorActor' - * factory object. - *

- * - * Here is a sample on how to use it: - *

- *  val supervisor = Supervisor(
- *    SupervisorConfig(
- *      RestartStrategy(OneForOne, 3, 10, List(classOf[Exception]),
- *      Supervise(
- *        myFirstActor,
- *        Permanent) ::
- *      Supervise(
- *        mySecondActor,
- *        Permanent) ::
- *      Nil))
- * 
- * - * You dynamically link and unlink child children using the 'link' and 'unlink' methods. - *
- * supervisor.link(child)
- * supervisor.unlink(child)
- * 
- * - * If you are using it from Java you have to use Supervisor.apply(..) like in: - *
- *   Supervisor supervisor = Supervisor.apply(
- *     SupervisorConfig(
- *       ..
- *   ))
- * 
- * - * @author Jonas Bonér - */ object Supervisor { - def apply(config: SupervisorConfig): Supervisor = SupervisorFactory(config).newInstance.start() -} -/** - * Use this factory instead of the Supervisor factory object if you want to control - * instantiation and starting of the Supervisor, if not then it is easier and better - * to use the Supervisor factory object. - *

- * Example usage: - *

- *  val factory = SupervisorFactory(
- *    SupervisorConfig(
- *      RestartStrategy(OneForOne, 3, 10, List(classOf[Exception]),
- *      Supervise(
- *        myFirstActor,
- *        Permanent) ::
- *      Supervise(
- *        mySecondActor,
- *        Permanent) ::
- *      Nil))
- * 
- * - * Then create a new Supervisor tree with the concrete Services we have defined. - * - *
- * val supervisor = factory.newInstance
- * supervisor.start() // start up all managed servers
- * 
- * - * @author Jonas Bonér - */ -case class SupervisorFactory(val config: SupervisorConfig) { - - def newInstance: Supervisor = newInstanceFor(config) - - def newInstanceFor(config: SupervisorConfig): Supervisor = { - val supervisor = new Supervisor(config.restartStrategy, config.maxRestartsHandler) - supervisor.configure(config) - supervisor.start() - } -} - -/** - * NOTE: - *

- * The supervisor class is only used for the configuration system when configuring supervisor - * hierarchies declaratively. Should not be used as part of the regular programming API. Instead - * wire the children together using 'link', 'startLink' etc. - *

- * See the ScalaDoc for the SupervisorFactory for an example on how to declaratively wire up children. - * - * @author Jonas Bonér - */ -sealed class Supervisor(handler: FaultHandlingStrategy, maxRestartsHandler: (ActorRef, Terminated) ⇒ Unit) { - import Supervisor._ - - private val _childActors = new CopyOnWriteArrayList[ActorRef] - private val _childSupervisors = new CopyOnWriteArrayList[Supervisor] - - private[akka] val supervisor = actorOf(Props(new SupervisorActor(maxRestartsHandler)).withFaultHandler(handler)) - - def uuid = supervisor.uuid - - def start(): Supervisor = { - this - } - - def shutdown(): Unit = supervisor.stop() - - def link(child: ActorRef) = supervisor.link(child) - - def unlink(child: ActorRef) = supervisor.unlink(child) - - def children: List[ActorRef] = { - val buf = new ListBuffer[ActorRef] - val i = _childActors.iterator() - while (i.hasNext) buf += i.next() - buf.toList - } - - def childSupervisors: List[Supervisor] = { - val buf = new ListBuffer[Supervisor] - val i = _childSupervisors.iterator() - while (i.hasNext) buf += i.next() - buf.toList - } - - def configure(config: SupervisorConfig): Unit = config match { - case SupervisorConfig(_, servers, _) ⇒ - servers foreach { - case Supervise(actorRef, lifeCycle, registerAsRemoteService) ⇒ - // actorRef.lifeCycle = lifeCycle THIS IS NOT COOL, BUT WAITING FOR https://www.assembla.com/spaces/akka/tickets/1124-supervisor-dsl-doesn-t-make-much-sense-after-the-introduction-of-props - supervisor.link(actorRef) - - _childActors.add(actorRef) //TODO Why do we keep this here, mem leak? - - if (ClusterModule.isEnabled && registerAsRemoteService) - Actor.remote.register(actorRef) - case supervisorConfig @ SupervisorConfig(_, _, _) ⇒ // recursive supervisor configuration - val childSupervisor = Supervisor(supervisorConfig) - supervisor.link(childSupervisor.supervisor) - _childSupervisors.add(childSupervisor) - } - } -} - -/** - * For internal use only. - * - * @author Jonas Bonér - */ -final class SupervisorActor private[akka] (maxRestartsHandler: (ActorRef, Terminated) ⇒ Unit) extends Actor { - - override def postStop() { - val i = linkedActors.iterator - while (i.hasNext) { - val ref = i.next - ref.stop() - self.unlink(ref) + class Supervisor(terminationHandling: (ActorContext, Terminated) ⇒ Unit) extends Actor { + def receive = { + case t: Terminated ⇒ terminationHandling(context, t) } } - def receive = { - case termination: Terminated ⇒ maxRestartsHandler(self, termination) - case unknown ⇒ throw new SupervisorException( - "SupervisorActor can not respond to messages.\n\tUnknown message [" + unknown + "]") - } -} + private val doNothing: (ActorContext, Terminated) ⇒ Unit = (_, _) ⇒ () + + def apply(faultHandler: FaultHandlingStrategy = Props.defaultFaultHandler, supervisor: ActorRef = null, + terminationHandling: (ActorContext, Terminated) ⇒ Unit = doNothing): ActorRef = + Actor.actorOf(Props(new Supervisor(terminationHandling)).withSupervisor(supervisor).withFaultHandler(faultHandler)) +} \ No newline at end of file diff --git a/akka-actor/src/main/scala/akka/config/Configurator.scala b/akka-actor/src/main/scala/akka/config/Configurator.scala deleted file mode 100644 index f0d067c5bc..0000000000 --- a/akka-actor/src/main/scala/akka/config/Configurator.scala +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (C) 2009-2011 Typesafe Inc. - */ - -package akka.config - -import akka.actor.FaultHandlingStrategy -import akka.config.Supervision.SuperviseTypedActor - -private[akka] trait TypedActorConfiguratorBase { - def getExternalDependency[T](clazz: Class[T]): T - - def configure(restartStrategy: FaultHandlingStrategy, components: List[SuperviseTypedActor]): TypedActorConfiguratorBase - - def inject: TypedActorConfiguratorBase - - def supervise: TypedActorConfiguratorBase - - def reset - - def stop -} diff --git a/akka-actor/src/main/scala/akka/config/SupervisionConfig.scala b/akka-actor/src/main/scala/akka/config/SupervisionConfig.scala deleted file mode 100644 index 3be551248a..0000000000 --- a/akka-actor/src/main/scala/akka/config/SupervisionConfig.scala +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Copyright (C) 2009-2011 Typesafe Inc. - */ - -package akka.config - -import akka.actor.FaultHandlingStrategy -import akka.dispatch.MessageDispatcher -import akka.actor.{ Terminated, ActorRef } -import akka.japi.{ Procedure2 } - -case class RemoteAddress(val hostname: String, val port: Int) - -/** - * Configuration classes - not to be used as messages. - * - * @author Jonas Bonér - */ -object Supervision { - sealed abstract class ConfigElement - - abstract class Server extends ConfigElement - sealed abstract class LifeCycle extends ConfigElement - - case class SupervisorConfig(restartStrategy: FaultHandlingStrategy, worker: List[Server], maxRestartsHandler: (ActorRef, Terminated) ⇒ Unit = { (aRef, max) ⇒ () }) extends Server { - //Java API - def this(restartStrategy: FaultHandlingStrategy, worker: Array[Server]) = this(restartStrategy, worker.toList) - def this(restartStrategy: FaultHandlingStrategy, worker: Array[Server], restartHandler: Procedure2[ActorRef, Terminated]) = this(restartStrategy, worker.toList, { (aRef, max) ⇒ restartHandler.apply(aRef, max) }) - } - - class Supervise(val actorRef: ActorRef, val lifeCycle: LifeCycle, val registerAsRemoteService: Boolean = false) extends Server { - //Java API - def this(actorRef: ActorRef, lifeCycle: LifeCycle) = - this(actorRef, lifeCycle, false) - } - - object Supervise { - def apply(actorRef: ActorRef, lifeCycle: LifeCycle, registerAsRemoteService: Boolean = false) = new Supervise(actorRef, lifeCycle, registerAsRemoteService) - def apply(actorRef: ActorRef, lifeCycle: LifeCycle) = new Supervise(actorRef, lifeCycle, false) - def unapply(supervise: Supervise) = Some((supervise.actorRef, supervise.lifeCycle, supervise.registerAsRemoteService)) - } - - //Scala API - case object Permanent extends LifeCycle - case object Temporary extends LifeCycle - - //Java API (& Scala if you fancy) - def permanent(): LifeCycle = Permanent - def temporary(): LifeCycle = Temporary - - case class SuperviseTypedActor(_intf: Class[_], - val target: Class[_], - val lifeCycle: LifeCycle, - val timeout: Long, - _dispatcher: MessageDispatcher // optional - ) extends Server { - val intf: Option[Class[_]] = Option(_intf) - val dispatcher: Option[MessageDispatcher] = Option(_dispatcher) - - def this(target: Class[_], lifeCycle: LifeCycle, timeout: Long) = - this(null: Class[_], target, lifeCycle, timeout, null: MessageDispatcher) - - def this(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Long) = - this(intf, target, lifeCycle, timeout, null: MessageDispatcher) - - def this(target: Class[_], lifeCycle: LifeCycle, timeout: Long, dispatcher: MessageDispatcher) = - this(null: Class[_], target, lifeCycle, timeout, dispatcher) - } -} diff --git a/akka-actor/src/main/scala/akka/routing/Pool.scala b/akka-actor/src/main/scala/akka/routing/Pool.scala index 3f9ffacac4..053b3ec345 100644 --- a/akka-actor/src/main/scala/akka/routing/Pool.scala +++ b/akka-actor/src/main/scala/akka/routing/Pool.scala @@ -5,7 +5,6 @@ package akka.routing import akka.dispatch.{ Promise } -import akka.config.Supervision._ import akka.actor._ /** diff --git a/akka-camel/src/test/scala/akka/camel/ConsumerScalaTest.scala b/akka-camel/src/test/scala/akka/camel/ConsumerScalaTest.scala index 8f847b9169..cc9e780df7 100644 --- a/akka-camel/src/test/scala/akka/camel/ConsumerScalaTest.scala +++ b/akka-camel/src/test/scala/akka/camel/ConsumerScalaTest.scala @@ -11,7 +11,6 @@ import org.scalatest.matchers.MustMatchers import akka.actor.Actor._ import akka.actor._ -import akka.config.Supervision._ /** * @author Martin Krasser diff --git a/akka-cluster/src/main/scala/akka/cluster/Cluster.scala b/akka-cluster/src/main/scala/akka/cluster/Cluster.scala index 33d180b915..aac831dec4 100644 --- a/akka-cluster/src/main/scala/akka/cluster/Cluster.scala +++ b/akka-cluster/src/main/scala/akka/cluster/Cluster.scala @@ -34,9 +34,8 @@ import DeploymentConfig._ import akka.event.EventHandler import akka.dispatch.{ Dispatchers, Future, PinnedDispatcher } -import akka.config.{ Config, Supervision } -import Supervision._ -import Config._ +import akka.config.Config +import akka.config.Config._ import akka.serialization.{ Serialization, Serializer, ActorSerialization, Compression } import ActorSerialization._ diff --git a/akka-durable-mailboxes/akka-mailboxes-common/src/test/scala/akka/actor/mailbox/DurableMailboxSpec.scala b/akka-durable-mailboxes/akka-mailboxes-common/src/test/scala/akka/actor/mailbox/DurableMailboxSpec.scala index 205d8b2b68..24d8e471b4 100644 --- a/akka-durable-mailboxes/akka-mailboxes-common/src/test/scala/akka/actor/mailbox/DurableMailboxSpec.scala +++ b/akka-durable-mailboxes/akka-mailboxes-common/src/test/scala/akka/actor/mailbox/DurableMailboxSpec.scala @@ -9,7 +9,6 @@ import org.scalatest.{ BeforeAndAfterEach, BeforeAndAfterAll } import akka.actor._ import akka.actor.Actor._ import java.util.concurrent.CountDownLatch -import akka.config.Supervision.Temporary import akka.dispatch.MessageDispatcher object DurableMailboxSpecActorFactory { diff --git a/akka-durable-mailboxes/akka-mongo-mailbox/src/test/scala/akka/actor/mailbox/MongoBasedMailboxSpec.scala b/akka-durable-mailboxes/akka-mongo-mailbox/src/test/scala/akka/actor/mailbox/MongoBasedMailboxSpec.scala index 1580e5c812..fca657727e 100644 --- a/akka-durable-mailboxes/akka-mongo-mailbox/src/test/scala/akka/actor/mailbox/MongoBasedMailboxSpec.scala +++ b/akka-durable-mailboxes/akka-mongo-mailbox/src/test/scala/akka/actor/mailbox/MongoBasedMailboxSpec.scala @@ -9,7 +9,6 @@ import org.scalatest.{ BeforeAndAfterEach, BeforeAndAfterAll } import akka.actor._ import akka.actor.Actor._ import java.util.concurrent.CountDownLatch -import akka.config.Supervision.Temporary import akka.dispatch.MessageDispatcher class MongoBasedMailboxSpec extends DurableMailboxSpec("mongodb", MongoNaiveDurableMailboxStorage) { diff --git a/akka-remote/src/main/scala/akka/remote/RemoteDaemon.scala b/akka-remote/src/main/scala/akka/remote/RemoteDaemon.scala index 38283d1ffd..437a3c288a 100644 --- a/akka-remote/src/main/scala/akka/remote/RemoteDaemon.scala +++ b/akka-remote/src/main/scala/akka/remote/RemoteDaemon.scala @@ -5,19 +5,18 @@ package akka.remote import akka.actor._ -import Actor._ +import akka.actor.Actor._ import akka.event.EventHandler import akka.dispatch.{ Dispatchers, Future, PinnedDispatcher } -import akka.config.{ Config, Supervision } -import Supervision._ -import Status._ -import Config._ +import akka.config.Config +import akka.config.Config._ +import akka.actor.Status._ import akka.util._ -import duration._ -import Helpers._ -import DeploymentConfig._ +import akka.util.duration._ +import akka.util.Helpers._ +import akka.actor.DeploymentConfig._ import akka.serialization.{ Serialization, Serializer, ActorSerialization, Compression } -import ActorSerialization._ +import akka.serialization.ActorSerialization._ import Compression.LZF import RemoteProtocol._ import RemoteDaemonMessageType._ @@ -41,18 +40,14 @@ object Remote extends RemoteService { // FIXME configure computeGridDispatcher to what? val computeGridDispatcher = Dispatchers.newDispatcher("akka:compute-grid").build - private[remote] lazy val remoteDaemon = new LocalActorRef( - Props(new RemoteDaemon).copy(dispatcher = new PinnedDispatcher()), - Remote.remoteDaemonServiceName, - systemService = true) - private[remote] lazy val remoteDaemonSupervisor = Supervisor( - SupervisorConfig( - OneForOneStrategy(List(classOf[Exception]), Int.MaxValue, Int.MaxValue), // is infinite restart what we want? - Supervise( - remoteDaemon, - Permanent) - :: Nil)) + OneForOneStrategy(List(classOf[Exception]), None, None)) // is infinite restart what we want? + + private[remote] lazy val remoteDaemon = + new LocalActorRef( + props = Props(new RemoteDaemon).withDispatcher(new PinnedDispatcher()).withSupervisor(remoteDaemonSupervisor), + address = Remote.remoteDaemonServiceName, + systemService = true) private[remote] lazy val remoteClientLifeCycleHandler = actorOf(Props(new Actor { def receive = { diff --git a/akka-remote/src/main/scala/akka/serialization/SerializationProtocol.scala b/akka-remote/src/main/scala/akka/serialization/SerializationProtocol.scala index 70641c0e9f..d7bf0821f7 100644 --- a/akka-remote/src/main/scala/akka/serialization/SerializationProtocol.scala +++ b/akka-remote/src/main/scala/akka/serialization/SerializationProtocol.scala @@ -4,10 +4,8 @@ package akka.serialization -import akka.config.Supervision._ -import akka.actor.{ uuidFrom, newUuid } import akka.actor._ -import DeploymentConfig._ +import akka.actor.DeploymentConfig._ import akka.dispatch.Envelope import akka.util.{ ReflectiveAccess, Duration } import akka.event.EventHandler @@ -192,14 +190,6 @@ object ActorSerialization { case e: Exception ⇒ Stack[PartialFunction[Any, Unit]]() } - val storedLifeCycle = - if (protocol.hasLifeCycle) { - protocol.getLifeCycle.getLifeCycle match { - case LifeCycleType.PERMANENT ⇒ Permanent - case LifeCycleType.TEMPORARY ⇒ Temporary - } - } else LifeCycleType.PERMANENT - val storedSupervisor = if (protocol.hasSupervisor) Some(RemoteActorSerialization.fromProtobufToRemoteActorRef(protocol.getSupervisor, loader)) else None diff --git a/akka-samples/akka-sample-camel/src/main/scala/sample/camel/Boot.scala b/akka-samples/akka-sample-camel/src/main/scala/sample/camel/Boot.scala index a1b7e92a0a..b84dd9c1c9 100644 --- a/akka-samples/akka-sample-camel/src/main/scala/sample/camel/Boot.scala +++ b/akka-samples/akka-sample-camel/src/main/scala/sample/camel/Boot.scala @@ -10,7 +10,6 @@ import akka.actor.Actor._ import akka.actor.Props import akka.actor.TypedActor import akka.camel.CamelContextManager -import akka.config.Supervision._ /** * @author Martin Krasser @@ -24,13 +23,6 @@ class Boot { actorOf[Consumer1] actorOf[Consumer2] - // Alternatively, use a supervisor for these actors - //val supervisor = Supervisor( - // SupervisorConfig( - // RestartStrategy(OneForOne, 3, 100, List(classOf[Exception])), - // Supervise(actorOf[Consumer1], Permanent) :: - // Supervise(actorOf[Consumer2], Permanent) :: Nil)) - // ----------------------------------------------------------------------- // Custom Camel route example // ----------------------------------------------------------------------- diff --git a/akka-samples/akka-sample-chat/src/main/scala/ChatServer.scala b/akka-samples/akka-sample-chat/src/main/scala/ChatServer.scala index 64944760ba..8b3718c348 100644 --- a/akka-samples/akka-sample-chat/src/main/scala/ChatServer.scala +++ b/akka-samples/akka-sample-chat/src/main/scala/ChatServer.scala @@ -8,8 +8,7 @@ import akka.actor.{Actor, ActorRef, Props} import akka.stm._ - import akka.config.Supervision.{OneForOneStrategy,Permanent} - import Actor._ + import akka.actor.Actor._ import akka.event.EventHandler /****************************************************************************** diff --git a/akka-samples/akka-sample-hello/src/main/scala/sample/hello/Boot.scala b/akka-samples/akka-sample-hello/src/main/scala/sample/hello/Boot.scala index 823ae024ee..149c6a3ee4 100644 --- a/akka-samples/akka-sample-hello/src/main/scala/sample/hello/Boot.scala +++ b/akka-samples/akka-sample-hello/src/main/scala/sample/hello/Boot.scala @@ -6,15 +6,9 @@ package sample.hello import akka.actor._ import akka.http._ -import akka.config.Supervision._ class Boot { - val factory = - SupervisorFactory( - SupervisorConfig( - OneForOneStrategy(List(classOf[Exception]), 3, 100), - Supervise(Actor.actorOf[RootEndpoint], Permanent) :: - Supervise(Actor.actorOf[HelloEndpoint], Permanent) :: Nil)) - - factory.newInstance.start() + val supervisor = Supervisor(OneForOneStrategy(List(classOf[Exception]), 3, 100)) + Actor.actorOf(Props[RootEndpoint].withSupervisor(supervisor)) + Actor.actorOf(Props[HelloEndpoint].withSupervisor(supervisor)) } diff --git a/akka-spring/src/main/scala/akka/spring/DispatcherFactoryBean.scala b/akka-spring/src/main/scala/akka/spring/DispatcherFactoryBean.scala index 8ba77319b8..47e0b0d54d 100644 --- a/akka-spring/src/main/scala/akka/spring/DispatcherFactoryBean.scala +++ b/akka-spring/src/main/scala/akka/spring/DispatcherFactoryBean.scala @@ -4,7 +4,6 @@ package akka.spring import org.springframework.beans.factory.config.AbstractFactoryBean -import akka.config.Supervision._ import AkkaSpringConfigurationTags._ import reflect.BeanProperty import akka.actor.ActorRef diff --git a/akka-spring/src/main/scala/akka/spring/SupervisionBeanDefinitionParser.scala b/akka-spring/src/main/scala/akka/spring/SupervisionBeanDefinitionParser.scala index 3979efab60..275d6f5326 100644 --- a/akka-spring/src/main/scala/akka/spring/SupervisionBeanDefinitionParser.scala +++ b/akka-spring/src/main/scala/akka/spring/SupervisionBeanDefinitionParser.scala @@ -5,7 +5,6 @@ package akka.spring import org.springframework.beans.factory.support.BeanDefinitionBuilder import org.springframework.beans.factory.xml.{ ParserContext, AbstractSingleBeanDefinitionParser } -import akka.config.Supervision._ import AkkaSpringConfigurationTags._ import org.w3c.dom.Element diff --git a/akka-spring/src/main/scala/akka/spring/SupervisionFactoryBean.scala b/akka-spring/src/main/scala/akka/spring/SupervisionFactoryBean.scala index 664513f809..14e685e93a 100644 --- a/akka-spring/src/main/scala/akka/spring/SupervisionFactoryBean.scala +++ b/akka-spring/src/main/scala/akka/spring/SupervisionFactoryBean.scala @@ -4,8 +4,7 @@ package akka.spring import org.springframework.beans.factory.config.AbstractFactoryBean -import akka.config.Supervision._ -import akka.actor.{ Supervisor, SupervisorFactory, Actor, ActorRegistry } +import akka.actor.{ Supervisor, Actor, ActorRegistry } import AkkaSpringConfigurationTags._ import reflect.BeanProperty import akka.config.{ TypedActorConfigurator, RemoteAddress } diff --git a/akka-spring/src/test/scala/DispatcherFactoryBeanTest.scala b/akka-spring/src/test/scala/DispatcherFactoryBeanTest.scala index 6bcdbd919c..27a41a802b 100644 --- a/akka-spring/src/test/scala/DispatcherFactoryBeanTest.scala +++ b/akka-spring/src/test/scala/DispatcherFactoryBeanTest.scala @@ -7,7 +7,6 @@ import org.scalatest.Spec import org.scalatest.matchers.ShouldMatchers import org.scalatest.junit.JUnitRunner import org.junit.runner.RunWith -import akka.config.Supervision._ import akka.dispatch.MessageDispatcher @RunWith(classOf[JUnitRunner]) diff --git a/akka-spring/src/test/scala/SupervisionBeanDefinitionParserTest.scala b/akka-spring/src/test/scala/SupervisionBeanDefinitionParserTest.scala index 2dc0445005..a0acbe75e5 100644 --- a/akka-spring/src/test/scala/SupervisionBeanDefinitionParserTest.scala +++ b/akka-spring/src/test/scala/SupervisionBeanDefinitionParserTest.scala @@ -11,7 +11,6 @@ import ScalaDom._ import org.w3c.dom.Element import org.springframework.beans.factory.support.BeanDefinitionBuilder -import akka.config.Supervision.{ FaultHandlingStrategy, AllForOneStrategy } /** * Test for SupervisionBeanDefinitionParser diff --git a/akka-spring/src/test/scala/SupervisionFactoryBeanTest.scala b/akka-spring/src/test/scala/SupervisionFactoryBeanTest.scala index f17e2cc92c..348b38dec2 100644 --- a/akka-spring/src/test/scala/SupervisionFactoryBeanTest.scala +++ b/akka-spring/src/test/scala/SupervisionFactoryBeanTest.scala @@ -7,7 +7,6 @@ import org.scalatest.Spec import org.scalatest.matchers.ShouldMatchers import org.scalatest.junit.JUnitRunner import org.junit.runner.RunWith -import akka.config.Supervision._ import akka.config.TypedActorConfigurator private[akka] class Foo