=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
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue