=doc #16614 Include best-practice tip on messages in companion object in docs

This commit is contained in:
Nikita Melkozerov 2015-01-16 23:43:27 +05:00
parent cedfaa35cc
commit a8632befc6
6 changed files with 89 additions and 0 deletions

View file

@ -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;