DOC: Added recommendation about naming actors and added name to some samples

This commit is contained in:
Patrik Nordwall 2011-12-16 00:39:29 +01:00
parent 6225b75b99
commit 164f92afd7
6 changed files with 25 additions and 17 deletions

View file

@ -7,7 +7,7 @@ import akka.actor.UntypedActor;
//#context-actorOf
public class FirstUntypedActor extends UntypedActor {
ActorRef myActor = getContext().actorOf(new Props(MyActor.class));
ActorRef myActor = getContext().actorOf(new Props(MyActor.class), "myactor");
//#context-actorOf

View file

@ -58,7 +58,7 @@ public class UntypedActorDocTestBase {
public void systemActorOf() {
//#system-actorOf
ActorSystem system = ActorSystem.create("MySystem");
ActorRef myActor = system.actorOf(new Props(MyUntypedActor.class));
ActorRef myActor = system.actorOf(new Props(MyUntypedActor.class), "myactor");
//#system-actorOf
myActor.tell("test");
system.shutdown();
@ -68,7 +68,7 @@ public class UntypedActorDocTestBase {
public void contextActorOf() {
//#context-actorOf
ActorSystem system = ActorSystem.create("MySystem");
ActorRef myActor = system.actorOf(new Props(MyUntypedActor.class));
ActorRef myActor = system.actorOf(new Props(MyUntypedActor.class), "myactor");
//#context-actorOf
myActor.tell("test");
system.shutdown();
@ -83,7 +83,7 @@ public class UntypedActorDocTestBase {
public UntypedActor create() {
return new MyActor("...");
}
}));
}), "myactor");
//#creating-constructor
myActor.tell("test");
system.shutdown();
@ -94,9 +94,8 @@ public class UntypedActorDocTestBase {
ActorSystem system = ActorSystem.create("MySystem");
//#creating-props
MessageDispatcher dispatcher = system.dispatcherFactory().lookup("my-dispatcher");
ActorRef myActor = system.actorOf(
new Props().withCreator(MyUntypedActor.class).withDispatcher(dispatcher),
"myactor");
ActorRef myActor = system.actorOf(new Props().withCreator(MyUntypedActor.class).withDispatcher(dispatcher),
"myactor");
//#creating-props
myActor.tell("test");
system.shutdown();
@ -109,7 +108,7 @@ public class UntypedActorDocTestBase {
public UntypedActor create() {
return new MyAskActor();
}
}));
}), "myactor");
//#using-ask
Future<Object> future = myActor.ask("Hello", 1000);