ActorContext instead of ActorRef in HotSwap code parameter. See #1441

This commit is contained in:
Patrik Nordwall 2011-12-07 11:25:35 +01:00
parent f7d6393027
commit 56dc18106b
6 changed files with 11 additions and 11 deletions

View file

@ -18,7 +18,7 @@ class HotSwapSpec extends AkkaSpec {
val a = system.actorOf(new Actor { val a = system.actorOf(new Actor {
def receive = { case _ _log += "default" } def receive = { case _ _log += "default" }
}) })
a ! HotSwap(self { a ! HotSwap(context {
case _ case _
_log += "swapped" _log += "swapped"
barrier.await barrier.await
@ -75,7 +75,7 @@ class HotSwapSpec extends AkkaSpec {
barrier.reset barrier.reset
_log = "" _log = ""
a ! HotSwap(self { a ! HotSwap(context {
case "swapped" case "swapped"
_log += "swapped" _log += "swapped"
barrier.await barrier.await

View file

@ -44,7 +44,7 @@ class ReceiveTimeoutSpec extends AkkaSpec {
val swappedLatch = TestLatch() val swappedLatch = TestLatch()
timeoutActor ! HotSwap(self { timeoutActor ! HotSwap(context {
case ReceiveTimeout swappedLatch.open case ReceiveTimeout swappedLatch.open
}) })

View file

@ -13,7 +13,7 @@ import akka.util.Duration
@org.junit.runner.RunWith(classOf[org.scalatest.junit.JUnitRunner]) @org.junit.runner.RunWith(classOf[org.scalatest.junit.JUnitRunner])
class ConfigSpec extends AkkaSpec(ConfigFactory.defaultReference) { class ConfigSpec extends AkkaSpec(ConfigFactory.defaultReference) {
"The default configuration file (i.e. akka-actor-reference.conf)" must { "The default configuration file (i.e. reference.conf)" must {
"contain all configuration properties for akka-actor that are used in code with their correct defaults" in { "contain all configuration properties for akka-actor that are used in code with their correct defaults" in {
val settings = system.settings val settings = system.settings

View file

@ -30,14 +30,14 @@ sealed trait AutoReceivedMessage extends Serializable
trait PossiblyHarmful trait PossiblyHarmful
case class HotSwap(code: ActorRef Actor.Receive, discardOld: Boolean = true) extends AutoReceivedMessage { case class HotSwap(code: ActorContext Actor.Receive, discardOld: Boolean = true) extends AutoReceivedMessage {
/** /**
* Java API * Java API
*/ */
def this(code: akka.japi.Function[ActorRef, Procedure[Any]], discardOld: Boolean) = { def this(code: akka.japi.Function[ActorContext, Procedure[Any]], discardOld: Boolean) = {
this((self: ActorRef) { this((context: ActorContext) {
val behavior = code(self) val behavior = code(context)
val result: Actor.Receive = { case msg behavior(msg) } val result: Actor.Receive = { case msg behavior(msg) }
result result
}, discardOld) }, discardOld)
@ -46,7 +46,7 @@ case class HotSwap(code: ActorRef ⇒ Actor.Receive, discardOld: Boolean = true)
/** /**
* Java API with default non-stacking behavior * Java API with default non-stacking behavior
*/ */
def this(code: akka.japi.Function[ActorRef, Procedure[Any]]) = this(code, true) def this(code: akka.japi.Function[ActorContext, Procedure[Any]]) = this(code, true)
} }
case class Failed(cause: Throwable) extends AutoReceivedMessage with PossiblyHarmful case class Failed(cause: Throwable) extends AutoReceivedMessage with PossiblyHarmful

View file

@ -509,7 +509,7 @@ private[akka] final class ActorCell(
if (system.settings.DebugAutoReceive) system.eventStream.publish(Debug(self.path.toString, "received AutoReceiveMessage " + msg)) if (system.settings.DebugAutoReceive) system.eventStream.publish(Debug(self.path.toString, "received AutoReceiveMessage " + msg))
msg.message match { msg.message match {
case HotSwap(code, discardOld) become(code(self), discardOld) case HotSwap(code, discardOld) become(code(this), discardOld)
case RevertHotSwap unbecome() case RevertHotSwap unbecome()
case Failed(cause) handleFailure(sender, cause) case Failed(cause) handleFailure(sender, cause)
case Kill throw new ActorKilledException("Kill") case Kill throw new ActorKilledException("Kill")

View file

@ -15,7 +15,7 @@ import akka.testkit.AkkaSpec
@RunWith(classOf[JUnitRunner]) @RunWith(classOf[JUnitRunner])
class ConfigSpec extends AkkaSpec(ConfigFactory.defaultReference) { class ConfigSpec extends AkkaSpec(ConfigFactory.defaultReference) {
"The default configuration file (i.e. akka-stm-reference.conf)" should { "The default configuration file (i.e. reference.conf)" should {
"contain all configuration properties for akka-stm that are used in code with their correct defaults" in { "contain all configuration properties for akka-stm that are used in code with their correct defaults" in {
val config = system.settings.config val config = system.settings.config
import config._ import config._