=doc #16614 Include best-practice tip on messages in companion object in docs
This commit is contained in:
parent
cedfaa35cc
commit
a8632befc6
6 changed files with 89 additions and 0 deletions
|
|
@ -535,6 +535,31 @@ public class UntypedActorDocTest {
|
|||
//#props-factory
|
||||
}
|
||||
|
||||
static
|
||||
//#messages-in-companion
|
||||
public class DemoMessagesActor extends UntypedActor {
|
||||
|
||||
static public class Greeting {
|
||||
private final String from;
|
||||
|
||||
public Greeting(String from) {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
public String getGreeter() {
|
||||
return from;
|
||||
}
|
||||
}
|
||||
|
||||
public void onReceive(Object message) throws Exception {
|
||||
if (message instanceof Greeting) {
|
||||
getSender().tell("Hello " + ((Greeting) message).getGreeter(), getSelf());
|
||||
} else
|
||||
unhandled(message);
|
||||
}
|
||||
}
|
||||
//#messages-in-companion
|
||||
|
||||
public static class MyActor extends UntypedActor {
|
||||
|
||||
final String s;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue