Merge branch 'wip-clean-up-actor-cell-jboner'
Signed-off-by: Jonas Bonér <jonas@jonasboner.com>
This commit is contained in:
commit
8c8680473a
92 changed files with 4064 additions and 631 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue