Convert remaining UntypedActor in docs #22182

This commit is contained in:
ortigali 2017-02-04 11:51:30 +05:00
parent 432b53c509
commit 760de5c6d4
39 changed files with 701 additions and 717 deletions

View file

@ -12,25 +12,27 @@ import org.junit.Test;
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;
import akka.actor.UntypedActor;
import akka.actor.AbstractActor;
import akka.testkit.JavaTestKit;
import scala.concurrent.duration.Duration;
public class TestKitSampleTest {
public static class SomeActor extends UntypedActor {
public static class SomeActor extends AbstractActor {
ActorRef target = null;
public void onReceive(Object msg) {
if (msg.equals("hello")) {
sender().tell("world", self());
if (target != null) target.forward(msg, getContext());
} else if (msg instanceof ActorRef) {
target = (ActorRef) msg;
sender().tell("done", self());
}
@Override
public Receive createReceive() {
return receiveBuilder()
.matchEquals("hello", message -> {
sender().tell("world", self());
if (target != null) target.forward(message, getContext());
})
.match(ActorRef.class, actorRef -> {
target = actorRef;
sender().tell("done", self());
})
.build();
}
}