=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

@ -152,6 +152,32 @@ public class ActorDocTest {
}
//#props-factory
static
//#messages-in-companion
public class DemoMessagesActor extends AbstractActor {
static public class Greeting {
private final String from;
public Greeting(String from) {
this.from = from;
}
public String getGreeter() {
return from;
}
}
DemoMessagesActor() {
receive(ReceiveBuilder.
match(Greeting.class, g -> {
log.info("I was greeted by {}", g.getGreeter());
}).build()
);
};
}
//#messages-in-companion
public static class Hook extends AbstractActor {
ActorRef target = null;
public Hook() {