change Java stash sample to become(), see #2642

This commit is contained in:
Roland 2012-11-06 11:41:50 +01:00
parent 8eec825f18
commit 657a24dbc8
3 changed files with 25 additions and 22 deletions

View file

@ -351,24 +351,23 @@ public class UntypedActorDocTestBase {
static
//#stash
public class ActorWithProtocol extends UntypedActorWithStash {
private Boolean isOpen = false;
public void onReceive(Object msg) {
if (isOpen) {
if (msg.equals("write")) {
// do writing...
} else if (msg.equals("close")) {
unstashAll();
isOpen = false;
} else {
stash();
}
if (msg.equals("open")) {
unstashAll();
getContext().become(new Procedure<Object>() {
public void apply(Object msg) throws Exception {
if (msg.equals("write")) {
// do writing...
} else if (msg.equals("close")) {
unstashAll();
getContext().unbecome();
} else {
stash();
}
}
}, false); // add behavior on top instead of replacing
} else {
if (msg.equals("open")) {
unstashAll();
isOpen = true;
} else {
stash();
}
stash();
}
}
}