Removed all 'actorOf' methods that does not take a 'Props', and changed all callers to use 'actorOf(Props(..))'

Signed-off-by: Jonas Bonér <jonas@jonasboner.com>
This commit is contained in:
Jonas Bonér 2011-12-13 14:09:40 +01:00
parent 86a5114d79
commit c9b787f029
85 changed files with 464 additions and 518 deletions

View file

@ -1,12 +1,13 @@
package akka.docs.actor;
import akka.actor.ActorRef;
import akka.actor.Props;
import static akka.actor.Actors.*;
import akka.actor.UntypedActor;
//#context-actorOf
public class FirstUntypedActor extends UntypedActor {
ActorRef myActor = getContext().actorOf(MyActor.class);
ActorRef myActor = getContext().actorOf(new Props(MyActor.class));
//#context-actorOf

View file

@ -2,6 +2,7 @@ package akka.docs.actor;
import static akka.docs.actor.UntypedActorSwapper.Swap.SWAP;
import akka.actor.ActorRef;
import akka.actor.Props;
import akka.actor.ActorSystem;
import akka.actor.UnhandledMessageException;
import akka.actor.UntypedActor;
@ -40,7 +41,7 @@ public class UntypedActorSwapper {
public static void main(String... args) {
ActorSystem system = ActorSystem.create("MySystem");
ActorRef swap = system.actorOf(Swapper.class);
ActorRef swap = system.actorOf(new Props(Swapper.class));
swap.tell(SWAP); // logs Hi
swap.tell(SWAP); // logs Ho
swap.tell(SWAP); // logs Hi
@ -50,4 +51,4 @@ public class UntypedActorSwapper {
}
}
//#swapper
//#swapper

View file

@ -3,6 +3,7 @@ package akka.docs.actor;
//#imports
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;
//#imports
@ -38,7 +39,7 @@ public class UntypedActorTestBase {
public void systemActorOf() {
//#system-actorOf
ActorSystem system = ActorSystem.create("MySystem");
ActorRef myActor = system.actorOf(MyUntypedActor.class);
ActorRef myActor = system.actorOf(new Props(MyUntypedActor.class));
//#system-actorOf
myActor.tell("test");
system.stop();
@ -48,7 +49,7 @@ public class UntypedActorTestBase {
public void contextActorOf() {
//#context-actorOf
ActorSystem system = ActorSystem.create("MySystem");
ActorRef myActor = system.actorOf(MyUntypedActor.class);
ActorRef myActor = system.actorOf(new Props(MyUntypedActor.class));
//#context-actorOf
myActor.tell("test");
system.stop();
@ -59,11 +60,11 @@ public class UntypedActorTestBase {
ActorSystem system = ActorSystem.create("MySystem");
//#creating-constructor
// allows passing in arguments to the MyActor constructor
ActorRef myActor = system.actorOf(new UntypedActorFactory() {
ActorRef myActor = system.actorOf(new Props(new UntypedActorFactory() {
public UntypedActor create() {
return new MyActor("...");
}
});
}));
//#creating-constructor
myActor.tell("test");
system.stop();
@ -74,8 +75,7 @@ public class UntypedActorTestBase {
ActorSystem system = ActorSystem.create("MySystem");
//#creating-props
MessageDispatcher dispatcher = system.dispatcherFactory().newFromConfig("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.stop();
@ -84,11 +84,11 @@ public class UntypedActorTestBase {
@Test
public void usingAsk() {
ActorSystem system = ActorSystem.create("MySystem");
ActorRef myActor = system.actorOf(new UntypedActorFactory() {
ActorRef myActor = system.actorOf(new Props(new UntypedActorFactory() {
public UntypedActor create() {
return new MyAskActor();
}
});
}));
//#using-ask
Future future = myActor.ask("Hello", 1000);
@ -109,7 +109,7 @@ public class UntypedActorTestBase {
@Test
public void receiveTimeout() {
ActorSystem system = ActorSystem.create("MySystem");
ActorRef myActor = system.actorOf(MyReceivedTimeoutUntypedActor.class);
ActorRef myActor = system.actorOf(new Props(MyReceivedTimeoutUntypedActor.class));
myActor.tell("Hello");
system.stop();
}
@ -117,7 +117,7 @@ public class UntypedActorTestBase {
@Test
public void usePoisonPill() {
ActorSystem system = ActorSystem.create("MySystem");
ActorRef myActor = system.actorOf(MyUntypedActor.class);
ActorRef myActor = system.actorOf(new Props(MyUntypedActor.class));
//#poison-pill
myActor.tell(poisonPill());
//#poison-pill
@ -127,7 +127,7 @@ public class UntypedActorTestBase {
@Test
public void useKill() {
ActorSystem system = ActorSystem.create("MySystem");
ActorRef victim = system.actorOf(MyUntypedActor.class);
ActorRef victim = system.actorOf(new Props(MyUntypedActor.class));
//#kill
victim.tell(kill());
//#kill
@ -137,11 +137,11 @@ public class UntypedActorTestBase {
@Test
public void useBecome() {
ActorSystem system = ActorSystem.create("MySystem");
ActorRef myActor = system.actorOf(new UntypedActorFactory() {
ActorRef myActor = system.actorOf(new Props(new UntypedActorFactory() {
public UntypedActor create() {
return new HotSwapActor();
}
});
}));
myActor.tell("foo");
myActor.tell("bar");
myActor.tell("bar");