EchoHandler Class — netty Architecture
Architecture documentation for the EchoHandler class in SocketObjectEchoTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD b75c2f1e_0706_3806_16e3_edbe61b769bc["EchoHandler"] e6441b19_4ea7_cefa_16d5_cc332a23b8ae["SocketObjectEchoTest.java"] b75c2f1e_0706_3806_16e3_edbe61b769bc -->|defined in| e6441b19_4ea7_cefa_16d5_cc332a23b8ae 8400ecb9_6ce0_eb65_95e7_42fb3dd1f7ef["EchoHandler()"] b75c2f1e_0706_3806_16e3_edbe61b769bc -->|method| 8400ecb9_6ce0_eb65_95e7_42fb3dd1f7ef 37fa9198_947f_7921_a13a_e3199647eb16["channelActive()"] b75c2f1e_0706_3806_16e3_edbe61b769bc -->|method| 37fa9198_947f_7921_a13a_e3199647eb16 22f9ebb4_e2a3_369b_1cdb_ad5bde0062eb["channelRead()"] b75c2f1e_0706_3806_16e3_edbe61b769bc -->|method| 22f9ebb4_e2a3_369b_1cdb_ad5bde0062eb 40ba7df0_7564_c222_ca3b_107f8e2bd54d["channelReadComplete()"] b75c2f1e_0706_3806_16e3_edbe61b769bc -->|method| 40ba7df0_7564_c222_ca3b_107f8e2bd54d ad5baa45_f9f0_16f8_2b8f_b554eb5abc5b["exceptionCaught()"] b75c2f1e_0706_3806_16e3_edbe61b769bc -->|method| ad5baa45_f9f0_16f8_2b8f_b554eb5abc5b
Relationship Graph
Source Code
testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketObjectEchoTest.java lines 155–203
private static class EchoHandler extends ChannelInboundHandlerAdapter {
private final boolean autoRead;
volatile Channel channel;
final AtomicReference<Throwable> exception = new AtomicReference<Throwable>();
volatile int counter;
EchoHandler(boolean autoRead) {
this.autoRead = autoRead;
}
@Override
public void channelActive(ChannelHandlerContext ctx)
throws Exception {
channel = ctx.channel();
if (!autoRead) {
ctx.read();
}
}
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
assertEquals(data[counter], msg);
if (channel.parent() != null) {
channel.write(msg);
}
counter ++;
}
@Override
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
try {
ctx.flush();
} finally {
if (!autoRead) {
ctx.read();
}
}
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx,
Throwable cause) throws Exception {
if (exception.compareAndSet(null, cause)) {
ctx.close();
}
}
}
Source
Frequently Asked Questions
What is the EchoHandler class?
EchoHandler is a class in the netty codebase, defined in testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketObjectEchoTest.java.
Where is EchoHandler defined?
EchoHandler is defined in testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketObjectEchoTest.java at line 155.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free