WorldClockClientHandler Class — netty Architecture
Architecture documentation for the WorldClockClientHandler class in WorldClockClientHandler.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD a0ad04a6_4b11_c1bd_e15e_95329df45e15["WorldClockClientHandler"] 909ad40b_2487_a76b_a05a_6fb5a484700c["WorldClockClientHandler.java"] a0ad04a6_4b11_c1bd_e15e_95329df45e15 -->|defined in| 909ad40b_2487_a76b_a05a_6fb5a484700c 1955ec6e_aeb2_12f0_307b_63339dca142d["WorldClockClientHandler()"] a0ad04a6_4b11_c1bd_e15e_95329df45e15 -->|method| 1955ec6e_aeb2_12f0_307b_63339dca142d 638d6878_76c7_50fe_ddfc_9df919b7d3e2["getLocalTimes()"] a0ad04a6_4b11_c1bd_e15e_95329df45e15 -->|method| 638d6878_76c7_50fe_ddfc_9df919b7d3e2 7f413f28_eb12_be10_b71a_83e1d75367a2["channelRegistered()"] a0ad04a6_4b11_c1bd_e15e_95329df45e15 -->|method| 7f413f28_eb12_be10_b71a_83e1d75367a2 bec5cc7c_c8fc_3505_7607_80f4a32feeb0["channelRead0()"] a0ad04a6_4b11_c1bd_e15e_95329df45e15 -->|method| bec5cc7c_c8fc_3505_7607_80f4a32feeb0 111d28c4_d8c0_6b7c_f9a5_90d59928258b["exceptionCaught()"] a0ad04a6_4b11_c1bd_e15e_95329df45e15 -->|method| 111d28c4_d8c0_6b7c_f9a5_90d59928258b
Relationship Graph
Source Code
example/src/main/java/io/netty/example/worldclock/WorldClockClientHandler.java lines 35–106
public class WorldClockClientHandler extends SimpleChannelInboundHandler<LocalTimes> {
private static final Pattern DELIM = Pattern.compile("/");
// Stateful properties
private volatile Channel channel;
private final BlockingQueue<LocalTimes> answer = new LinkedBlockingQueue<LocalTimes>();
public WorldClockClientHandler() {
super(false);
}
public List<String> getLocalTimes(Collection<String> cities) {
Locations.Builder builder = Locations.newBuilder();
for (String c: cities) {
String[] components = DELIM.split(c);
builder.addLocation(Location.newBuilder().
setContinent(Continent.valueOf(components[0].toUpperCase())).
setCity(components[1]).build());
}
channel.writeAndFlush(builder.build());
LocalTimes localTimes;
boolean interrupted = false;
for (;;) {
try {
localTimes = answer.take();
break;
} catch (InterruptedException ignore) {
interrupted = true;
}
}
if (interrupted) {
Thread.currentThread().interrupt();
}
List<String> result = new ArrayList<String>();
for (LocalTime lt: localTimes.getLocalTimeList()) {
result.add(
new Formatter().format(
"%4d-%02d-%02d %02d:%02d:%02d %s",
lt.getYear(),
lt.getMonth(),
lt.getDayOfMonth(),
lt.getHour(),
lt.getMinute(),
lt.getSecond(),
lt.getDayOfWeek().name()).toString());
}
return result;
}
@Override
public void channelRegistered(ChannelHandlerContext ctx) {
channel = ctx.channel();
}
@Override
public void channelRead0(ChannelHandlerContext ctx, LocalTimes times) throws Exception {
answer.add(times);
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
cause.printStackTrace();
ctx.close();
}
}
Source
Frequently Asked Questions
What is the WorldClockClientHandler class?
WorldClockClientHandler is a class in the netty codebase, defined in example/src/main/java/io/netty/example/worldclock/WorldClockClientHandler.java.
Where is WorldClockClientHandler defined?
WorldClockClientHandler is defined in example/src/main/java/io/netty/example/worldclock/WorldClockClientHandler.java at line 35.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free