Correction of Java doc Creating Actors Remotely, see #2537
This commit is contained in:
parent
c0f60da8cc
commit
ee65dbf184
5 changed files with 48 additions and 45 deletions
|
|
@ -1,21 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2009-2012 Typesafe Inc. <http://www.typesafe.com>
|
||||
*/
|
||||
package docs.remoting;
|
||||
|
||||
import akka.actor.ActorRef;
|
||||
import akka.actor.UntypedActor;
|
||||
|
||||
public class RemoteActorExample extends UntypedActor {
|
||||
//#localNodeActor
|
||||
ActorRef a1 = getContext().actorFor("/serviceA/retrieval");
|
||||
//#localNodeActor
|
||||
|
||||
//#remoteNodeActor
|
||||
ActorRef a2 = getContext().actorFor("akka://app@10.0.0.1:2552/user/serviceA/retrieval");
|
||||
//#remoteNodeActor
|
||||
|
||||
public void onReceive(Object message) throws Exception {
|
||||
// Do something
|
||||
}
|
||||
}
|
||||
|
|
@ -17,7 +17,17 @@ import akka.actor.ActorSystem;
|
|||
import akka.remote.RemoteScope;
|
||||
//#import
|
||||
|
||||
import akka.actor.UntypedActor;
|
||||
|
||||
public class RemoteDeploymentDocTestBase {
|
||||
|
||||
//#sample-actor
|
||||
public static class Echo extends UntypedActor {
|
||||
public void onReceive(Object message) {
|
||||
getSender().tell(getSelf(), getSelf());
|
||||
}
|
||||
}
|
||||
//#sample-actor
|
||||
|
||||
static ActorSystem system;
|
||||
|
||||
|
|
@ -38,9 +48,19 @@ public class RemoteDeploymentDocTestBase {
|
|||
addr = AddressFromURIString.parse("akka://sys@host:1234"); // the same
|
||||
//#make-address
|
||||
//#deploy
|
||||
ActorRef ref = system.actorOf(new Props(RemoteDeploymentDocSpec.Echo.class).withDeploy(new Deploy(new RemoteScope(addr))));
|
||||
ActorRef ref = system.actorOf(new Props(Echo.class).withDeploy(new Deploy(new RemoteScope(addr))));
|
||||
//#deploy
|
||||
assert ref.path().address().equals(addr);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void demonstrateSampleActor() {
|
||||
//#sample-actor
|
||||
|
||||
ActorRef actor = system.actorOf(new Props(Echo.class), "sampleActor");
|
||||
actor.tell("Pretty slick", null);
|
||||
//#sample-actor
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue