diff --git a/akka-actor-tests/src/test/scala/akka/event/LoggingReceiveSpec.scala b/akka-actor-tests/src/test/scala/akka/event/LoggingReceiveSpec.scala index b632bd3c40..00c2e7d406 100644 --- a/akka-actor-tests/src/test/scala/akka/event/LoggingReceiveSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/event/LoggingReceiveSpec.scala @@ -56,11 +56,12 @@ class LoggingReceiveSpec extends WordSpec with BeforeAndAfterEach with BeforeAnd "decorate a Receive" in { new TestKit(appLogging) { system.eventStream.subscribe(testActor, classOf[Logging.Debug]) - val r: Actor.Receive = { - case null ⇒ - } - val log = LoggingReceive("funky")(r) - log.isDefinedAt("hallo") + val a = system.actorOf(Props(new Actor { + def receive = LoggingReceive("funky") { + case null ⇒ + } + })) + a ! "hallo" expectMsg(1 second, Logging.Debug("funky", classOf[DummyClassForStringSources], "received unhandled message hallo")) } } diff --git a/akka-actor/src/main/scala/akka/event/LoggingReceive.scala b/akka-actor/src/main/scala/akka/event/LoggingReceive.scala index 92a4166be8..e313ee59f9 100644 --- a/akka-actor/src/main/scala/akka/event/LoggingReceive.scala +++ b/akka-actor/src/main/scala/akka/event/LoggingReceive.scala @@ -4,7 +4,7 @@ package akka.event import akka.actor.Actor.Receive -import akka.actor.ActorSystem +import akka.actor.ActorContext import akka.event.Logging.Debug object LoggingReceive { @@ -23,21 +23,21 @@ object LoggingReceive { * This method does NOT modify the given Receive unless * akka.actor.debug.receive is set within akka.conf. */ - def apply(source: AnyRef)(r: Receive)(implicit system: ActorSystem): Receive = r match { - case _: LoggingReceive ⇒ r - case _ if !system.settings.AddLoggingReceive ⇒ r - case _ ⇒ new LoggingReceive(source, r) + def apply(source: AnyRef)(r: Receive)(implicit context: ActorContext): Receive = r match { + case _: LoggingReceive ⇒ r + case _ if !context.system.settings.AddLoggingReceive ⇒ r + case _ ⇒ new LoggingReceive(source, r) } } /** * This decorator adds invocation logging to a Receive function. */ -class LoggingReceive(source: AnyRef, r: Receive)(implicit system: ActorSystem) extends Receive { +class LoggingReceive(source: AnyRef, r: Receive)(implicit context: ActorContext) extends Receive { def isDefinedAt(o: Any) = { val handled = r.isDefinedAt(o) val (str, clazz) = LogSource.fromAnyRef(source) - system.eventStream.publish(Debug(str, clazz, "received " + (if (handled) "handled" else "unhandled") + " message " + o)) + context.system.eventStream.publish(Debug(str, clazz, "received " + (if (handled) "handled" else "unhandled") + " message " + o)) handled } def apply(o: Any): Unit = r(o) diff --git a/akka-docs/scala/code/akka/docs/actor/FaultHandlingDocSample.scala b/akka-docs/scala/code/akka/docs/actor/FaultHandlingDocSample.scala index 1b013cd50e..f6661ef92a 100644 --- a/akka-docs/scala/code/akka/docs/actor/FaultHandlingDocSample.scala +++ b/akka-docs/scala/code/akka/docs/actor/FaultHandlingDocSample.scala @@ -68,7 +68,6 @@ object Worker { class Worker extends Actor with ActorLogging { import Worker._ import CounterService._ - implicit def system = context.system implicit val askTimeout = Timeout(5 seconds) // Stop the CounterService child if it throws ServiceUnavailable @@ -113,7 +112,6 @@ class CounterService extends Actor { import CounterService._ import Counter._ import Storage._ - implicit def system = context.system // Restart the storage child when StorageException is thrown. // After 3 restarts within 5 seconds it will be stopped. @@ -204,7 +202,6 @@ class Counter(key: String, initialValue: Long) extends Actor { import Counter._ import CounterService._ import Storage._ - implicit def system = context.system var count = initialValue var storage: Option[ActorRef] = None @@ -246,7 +243,6 @@ object Storage { */ class Storage extends Actor { import Storage._ - implicit def system = context.system val db = DummyDB diff --git a/akka-docs/scala/code/akka/docs/testkit/TestkitDocSpec.scala b/akka-docs/scala/code/akka/docs/testkit/TestkitDocSpec.scala index 22285851f4..bcd8b63a9e 100644 --- a/akka-docs/scala/code/akka/docs/testkit/TestkitDocSpec.scala +++ b/akka-docs/scala/code/akka/docs/testkit/TestkitDocSpec.scala @@ -61,7 +61,6 @@ object TestkitDocSpec { class LoggingActor extends Actor { //#logging-receive import akka.event.LoggingReceive - implicit def system = context.system def receive = LoggingReceive(this) { case msg ⇒ // Do something... }