Java style accessors for AbstractFSM #22592

This commit is contained in:
Johan Andrén 2017-03-17 10:18:15 +01:00
parent 363ca39f52
commit 07e88300bc
24 changed files with 85 additions and 58 deletions

View file

@ -87,7 +87,7 @@ public class EchoHandler extends AbstractActor {
.match(ConnectionClosed.class, msg -> {
if (msg.isPeerClosed()) {
if (storage.isEmpty()) {
getContext().stop(self());
getContext().stop(getSelf());
} else {
getContext().become(closing());
}
@ -119,7 +119,7 @@ public class EchoHandler extends AbstractActor {
if (msg.isPeerClosed())
state.peerClosed = true;
else
getContext().stop(self());
getContext().stop(getSelf());
})
.match(Integer.class, ack -> {
@ -130,7 +130,7 @@ public class EchoHandler extends AbstractActor {
if (storage.isEmpty()) {
if (state.peerClosed)
getContext().stop(self());
getContext().stop(getSelf());
else
getContext().become(writing);
@ -165,7 +165,7 @@ public class EchoHandler extends AbstractActor {
.match(Integer.class, msg -> {
acknowledge(msg);
if (storage.isEmpty())
getContext().stop(self());
getContext().stop(getSelf());
})
.build();
}
@ -197,7 +197,7 @@ public class EchoHandler extends AbstractActor {
if (stored > MAX_STORED) {
log.warning("drop connection to [{}] (buffer overrun)", remote);
getContext().stop(self());
getContext().stop(getSelf());
} else if (stored > HIGH_WATERMARK) {
log.debug("suspending reading at {}", currentOffset());

View file

@ -40,14 +40,14 @@ public class EchoManager extends AbstractActor {
final ActorRef tcpManager = Tcp.get(getContext().getSystem()).manager();
//#manager
tcpManager.tell(
TcpMessage.bind(self(), new InetSocketAddress("localhost", 0), 100),
TcpMessage.bind(getSelf(), new InetSocketAddress("localhost", 0), 100),
getSelf());
}
@Override
public void postRestart(Throwable arg0) throws Exception {
// do not restart
getContext().stop(self());
getContext().stop(getSelf());
}
@Override
@ -59,7 +59,7 @@ public class EchoManager extends AbstractActor {
.match(Tcp.CommandFailed.class, failed -> {
if (failed.cmd() instanceof Bind) {
log.warning("cannot bind to [{}]", ((Bind) failed.cmd()).localAddress());
getContext().stop(self());
getContext().stop(getSelf());
} else {
log.warning("unknown command failed [{}]", failed.cmd());
}

View file

@ -48,7 +48,7 @@ public class IODocTest extends AbstractJavaTest {
@Override
public void preStart() throws Exception {
final ActorRef tcp = Tcp.get(getContext().getSystem()).manager();
tcp.tell(TcpMessage.bind(self(),
tcp.tell(TcpMessage.bind(getSelf(),
new InetSocketAddress("localhost", 0), 100), getSelf());
}
@ -60,7 +60,7 @@ public class IODocTest extends AbstractJavaTest {
})
.match(CommandFailed.class, msg -> {
getContext().stop(self());
getContext().stop(getSelf());
})
.match(Connected.class, conn -> {
@ -87,7 +87,7 @@ public class IODocTest extends AbstractJavaTest {
getSender().tell(TcpMessage.write(data), getSelf());
})
.match(ConnectionClosed.class, msg -> {
getContext().stop(self());
getContext().stop(getSelf());
})
.build();
}
@ -118,13 +118,13 @@ public class IODocTest extends AbstractJavaTest {
return receiveBuilder()
.match(CommandFailed.class, msg -> {
listener.tell("failed", getSelf());
getContext().stop(self());
getContext().stop(getSelf());
})
.match(Connected.class, msg -> {
listener.tell(msg, getSelf());
getSender().tell(TcpMessage.register(self()), getSelf());
getContext().become(connected(sender()));
getSender().tell(TcpMessage.register(getSelf()), getSelf());
getContext().become(connected(getSender()));
})
.build();
}
@ -144,7 +144,7 @@ public class IODocTest extends AbstractJavaTest {
connection.tell(TcpMessage.close(), getSelf());
})
.match(ConnectionClosed.class, msg -> {
getContext().stop(self());
getContext().stop(getSelf());
})
.build();
}

View file

@ -51,7 +51,7 @@ public class SimpleEchoHandler extends AbstractActor {
})
.match(ConnectionClosed.class, msg -> {
getContext().stop(self());
getContext().stop(getSelf());
})
.build();
}
@ -71,7 +71,7 @@ public class SimpleEchoHandler extends AbstractActor {
closing = true;
} else {
// could also be ErrorClosed, in which case we just give up
getContext().stop(self());
getContext().stop(getSelf());
}
})
.build();
@ -98,7 +98,7 @@ public class SimpleEchoHandler extends AbstractActor {
if (stored > maxStored) {
log.warning("drop connection to [{}] (buffer overrun)", remote);
getContext().stop(self());
getContext().stop(getSelf());
} else if (stored > highWatermark) {
log.debug("suspending reading");
@ -120,7 +120,7 @@ public class SimpleEchoHandler extends AbstractActor {
if (storage.isEmpty()) {
if (closing) {
getContext().stop(self());
getContext().stop(getSelf());
} else {
getContext().unbecome();
}

View file

@ -29,7 +29,7 @@ public class Watcher extends AbstractActor {
})
.match(Terminated.class, msg -> {
latch.countDown();
if (latch.getCount() == 0) getContext().stop(self());
if (latch.getCount() == 0) getContext().stop(getSelf());
})
.build();
}