clarify context needed for ActorDSL.actor() and add @implicitNotFound

This commit is contained in:
Roland 2013-02-27 13:50:46 +01:00
parent 6321663471
commit 36cbf96d8e
3 changed files with 14 additions and 4 deletions

View file

@ -7,14 +7,21 @@ package akka.actor
import language.postfixOps
import akka.testkit.{ AkkaSpec, EventFilter }
//#import
import akka.actor.ActorDSL._
//#import
import akka.event.Logging.Warning
import scala.concurrent.{ Await, Future }
import scala.concurrent.duration._
import java.util.concurrent.TimeoutException
class ActorDSLDummy {
//#import
import akka.actor.ActorDSL._
import akka.actor.ActorSystem
implicit val system = ActorSystem("demo")
//#import
}
class ActorDSLSpec extends AkkaSpec {
val echo = system.actorOf(Props(new Actor {

View file

@ -13,6 +13,7 @@ import akka.util.Collections.EmptyImmutableSeq
import scala.util.{ Success, Failure }
import java.util.concurrent.atomic.AtomicLong
import scala.concurrent.{ ExecutionContext, Future, Promise }
import scala.annotation.implicitNotFound
/**
* Interface for all ActorRef providers to implement.
@ -156,6 +157,7 @@ trait ActorRefProvider {
* Interface implemented by ActorSystem and ActorContext, the only two places
* from which you can get fresh actors.
*/
@implicitNotFound("implicit ActorRefFactory required: if outside of an Actor you need an implicit ActorSystem, inside of an actor this should be the implicit ActorContext")
trait ActorRefFactory {
/**
* INTERNAL API

View file

@ -162,8 +162,9 @@ infrastructure is bundled in the following import:
.. includecode:: ../../../akka-actor-tests/src/test/scala/akka/actor/ActorDSLSpec.scala#import
This import is assumed for all code samples throughout this section. To define
a simple actor, the following is sufficient:
This import is assumed for all code samples throughout this section. The
implicit actor system serves as :class:`ActorRefFactory` for all examples
below. To define a simple actor, the following is sufficient:
.. includecode:: ../../../akka-actor-tests/src/test/scala/akka/actor/ActorDSLSpec.scala#simple-actor