improve AbstractActor, #21717

* Receive class that wraps PartialFunction, to avoid
  scary scala types
* move AbstractActorContext to AbstractActor.ActorContext
* converting docs, many, many UntypedActor
* removing UntypedActor docs
* add unit test for ReceiveBuilder
* MiMa filters
* consistent use of getContext(), self(), sender()
* rename cross references
* migration guide
* skip samples for now
* improve match type safetyi, add matchUnchecked
  * the `? extends P` caused code like this to compile:
    `match(String.class, (Integer i) -> {})`
  * added matchUnchecked, since it can still be useful (um, convenient)
    to be able to do:
    `matchUnchecked(List.class, (List<String> list) -> {})`
* eleminate some scala.Option
  * preRestart
  * findChild
  * ActorIdentity.getActorRef
This commit is contained in:
Patrik Nordwall 2016-12-13 10:59:29 +01:00
parent 3617fe8b41
commit 4bd6b7aab1
157 changed files with 3290 additions and 8882 deletions

View file

@ -28,7 +28,7 @@ public class ParentChildTest {
//#test-example
static class Parent extends UntypedActor {
final ActorRef child = context().actorOf(Props.create(Child.class), "child");
final ActorRef child = getContext().actorOf(Props.create(Child.class), "child");
boolean ponged = false;
@Override public void onReceive(Object message) throws Exception {
@ -45,7 +45,7 @@ public class ParentChildTest {
static class Child extends UntypedActor {
@Override public void onReceive(Object message) throws Exception {
if ("ping".equals(message)) {
context().parent().tell("pong", self());
getContext().parent().tell("pong", self());
} else {
unhandled(message);
}
@ -79,7 +79,7 @@ public class ParentChildTest {
boolean ponged = false;
public DependentParent(Props childProps) {
child = context().actorOf(childProps, "child");
child = getContext().actorOf(childProps, "child");
}
@Override public void onReceive(Object message) throws Exception {
@ -102,7 +102,7 @@ public class ParentChildTest {
public GenericDependentParent(Function<ActorRefFactory, ActorRef> childMaker)
throws Exception {
child = childMaker.apply(context());
child = childMaker.apply(getContext());
}
@Override public void onReceive(Object message) throws Exception {
@ -175,13 +175,13 @@ public class ParentChildTest {
@Override public Actor create() throws Exception {
return new UntypedActor() {
final ActorRef child = context().actorOf(Props.create(Child.class), "child");
final ActorRef child = getContext().actorOf(Props.create(Child.class), "child");
@Override public void onReceive(Object x) throws Exception {
if (sender().equals(child)) {
proxy.ref().forward(x, context());
proxy.ref().forward(x, getContext());
} else {
child.forward(x, context());
child.forward(x, getContext());
}
}
};

View file

@ -37,7 +37,7 @@ public class TestKitDocTest {
static class MyActor extends UntypedActor {
public void onReceive(Object o) throws Exception {
if (o.equals("say42")) {
getSender().tell(42, getSelf());
sender().tell(42, self());
} else if (o instanceof Exception) {
throw (Exception) o;
}

View file

@ -24,12 +24,12 @@ public class TestKitSampleTest {
public void onReceive(Object msg) {
if (msg.equals("hello")) {
getSender().tell("world", getSelf());
sender().tell("world", self());
if (target != null) target.forward(msg, getContext());
} else if (msg instanceof ActorRef) {
target = (ActorRef) msg;
getSender().tell("done", getSelf());
sender().tell("done", self());
}
}
}