Java style accessors for AbstractFSM #22592
This commit is contained in:
parent
363ca39f52
commit
07e88300bc
24 changed files with 85 additions and 58 deletions
|
|
@ -46,7 +46,7 @@ public class JavaReadBackPressure {
|
|||
tcp = Tcp.get(getContext().getSystem()).manager();
|
||||
final List<Inet.SocketOption> options = new ArrayList<Inet.SocketOption>();
|
||||
tcp.tell(
|
||||
TcpMessage.bind(self(), new InetSocketAddress("localhost", 0), 100, options, true),
|
||||
TcpMessage.bind(getSelf(), new InetSocketAddress("localhost", 0), 100, options, true),
|
||||
getSelf()
|
||||
);
|
||||
//#pull-mode-bind
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ public class JavaUdpMulticast {
|
|||
final ActorRef mgr = Udp.get(getContext().getSystem()).getManager();
|
||||
// listen for datagrams on this address
|
||||
InetSocketAddress endpoint = new InetSocketAddress(port);
|
||||
mgr.tell(UdpMessage.bind(self(), endpoint, options), getSelf());
|
||||
mgr.tell(UdpMessage.bind(getSelf(), endpoint, options), getSelf());
|
||||
//#bind
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public class UdpDocTest {
|
|||
public Receive createReceive() {
|
||||
return receiveBuilder()
|
||||
.match(Udp.SimpleSenderReady.class, message -> {
|
||||
getContext().become(ready(sender()));
|
||||
getContext().become(ready(getSender()));
|
||||
//#sender
|
||||
getSender().tell(UdpMessage.send(ByteString.fromString("hello"), remote), getSelf());
|
||||
//#sender
|
||||
|
|
@ -68,7 +68,7 @@ public class UdpDocTest {
|
|||
// request creation of a bound listen socket
|
||||
final ActorRef mgr = Udp.get(getContext().getSystem()).getManager();
|
||||
mgr.tell(
|
||||
UdpMessage.bind(self(), new InetSocketAddress("localhost", 0)),
|
||||
UdpMessage.bind(getSelf(), new InetSocketAddress("localhost", 0)),
|
||||
getSelf());
|
||||
}
|
||||
|
||||
|
|
@ -116,14 +116,14 @@ public class UdpDocTest {
|
|||
|
||||
// create a restricted a.k.a. “connected” socket
|
||||
final ActorRef mgr = UdpConnected.get(getContext().getSystem()).getManager();
|
||||
mgr.tell(UdpConnectedMessage.connect(self(), remote), getSelf());
|
||||
mgr.tell(UdpConnectedMessage.connect(getSelf(), remote), getSelf());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Receive createReceive() {
|
||||
return receiveBuilder()
|
||||
.match(UdpConnected.Connected.class, message -> {
|
||||
getContext().become(ready(sender()));
|
||||
getContext().become(ready(getSender()));
|
||||
//#connected
|
||||
getSender()
|
||||
.tell(UdpConnectedMessage.send(ByteString.fromString("hello")),
|
||||
|
|
@ -154,7 +154,7 @@ public class UdpDocTest {
|
|||
connection.tell(message, getSelf());
|
||||
})
|
||||
.match(UdpConnected.Disconnected.class, x -> {
|
||||
getContext().stop(self());
|
||||
getContext().stop(getSelf());
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue