AbstractChannelHandlerContext Class — netty Architecture
Architecture documentation for the AbstractChannelHandlerContext class in AbstractChannelHandlerContext.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 219fdd98_e8e7_d4f7_fea0_eba60352e3de["AbstractChannelHandlerContext"] c58110f1_60ae_157d_f668_f5a6356af671["AbstractChannelHandlerContext.java"] 219fdd98_e8e7_d4f7_fea0_eba60352e3de -->|defined in| c58110f1_60ae_157d_f668_f5a6356af671 bd4fe53b_df2f_960b_6dfb_f6e89093bc14["AbstractChannelHandlerContext()"] 219fdd98_e8e7_d4f7_fea0_eba60352e3de -->|method| bd4fe53b_df2f_960b_6dfb_f6e89093bc14 ec619586_f0d2_fa54_4e08_86c787ac93eb["Channel()"] 219fdd98_e8e7_d4f7_fea0_eba60352e3de -->|method| ec619586_f0d2_fa54_4e08_86c787ac93eb 2a96776b_7f26_1f0c_f2b6_2a94592cd2c9["ChannelPipeline()"] 219fdd98_e8e7_d4f7_fea0_eba60352e3de -->|method| 2a96776b_7f26_1f0c_f2b6_2a94592cd2c9 423a4bfe_7b2d_70a0_f56f_9e0637afcf85["ByteBufAllocator()"] 219fdd98_e8e7_d4f7_fea0_eba60352e3de -->|method| 423a4bfe_7b2d_70a0_f56f_9e0637afcf85 cc234e1d_3bd4_b473_7c85_81e1a844209d["EventExecutor()"] 219fdd98_e8e7_d4f7_fea0_eba60352e3de -->|method| cc234e1d_3bd4_b473_7c85_81e1a844209d 6735bc14_4995_e8b2_701c_6829b9c80fcf["String()"] 219fdd98_e8e7_d4f7_fea0_eba60352e3de -->|method| 6735bc14_4995_e8b2_701c_6829b9c80fcf 9c9ad831_2d8b_b01e_bd08_eb0bcb8e44d7["ChannelHandlerContext()"] 219fdd98_e8e7_d4f7_fea0_eba60352e3de -->|method| 9c9ad831_2d8b_b01e_bd08_eb0bcb8e44d7 30046b18_f2a1_3cc6_01ab_3f4741be5605["invokeExceptionCaught()"] 219fdd98_e8e7_d4f7_fea0_eba60352e3de -->|method| 30046b18_f2a1_3cc6_01ab_3f4741be5605 ecdd9021_5139_5faf_c9e9_00ec51590b75["ChannelFuture()"] 219fdd98_e8e7_d4f7_fea0_eba60352e3de -->|method| ecdd9021_5139_5faf_c9e9_00ec51590b75 a820d060_ce06_963c_f17f_2845ce23a56c["ChannelPromise()"] 219fdd98_e8e7_d4f7_fea0_eba60352e3de -->|method| a820d060_ce06_963c_f17f_2845ce23a56c 99283ae3_ac1e_c2ab_31c8_7eec0221bc1c["write()"] 219fdd98_e8e7_d4f7_fea0_eba60352e3de -->|method| 99283ae3_ac1e_c2ab_31c8_7eec0221bc1c 7dbc9027_cf83_9c14_3f3e_8458eb46f7b9["validateWrite()"] 219fdd98_e8e7_d4f7_fea0_eba60352e3de -->|method| 7dbc9027_cf83_9c14_3f3e_8458eb46f7b9 b1146ab2_830a_2f47_42f2_bc9ab969ab97["notifyOutboundHandlerException()"] 219fdd98_e8e7_d4f7_fea0_eba60352e3de -->|method| b1146ab2_830a_2f47_42f2_bc9ab969ab97
Relationship Graph
Source Code
transport/src/main/java/io/netty/channel/AbstractChannelHandlerContext.java lines 60–1168
abstract class AbstractChannelHandlerContext implements ChannelHandlerContext, ResourceLeakHint {
private static final InternalLogger logger = InternalLoggerFactory.getInstance(AbstractChannelHandlerContext.class);
volatile AbstractChannelHandlerContext next;
volatile AbstractChannelHandlerContext prev;
private static final AtomicIntegerFieldUpdater<AbstractChannelHandlerContext> HANDLER_STATE_UPDATER =
AtomicIntegerFieldUpdater.newUpdater(AbstractChannelHandlerContext.class, "handlerState");
/**
* {@link ChannelHandler#handlerAdded(ChannelHandlerContext)} is about to be called.
*/
private static final int ADD_PENDING = 1;
/**
* {@link ChannelHandler#handlerAdded(ChannelHandlerContext)} was called.
*/
private static final int ADD_COMPLETE = 2;
/**
* {@link ChannelHandler#handlerRemoved(ChannelHandlerContext)} was called.
*/
private static final int REMOVE_COMPLETE = 3;
/**
* Neither {@link ChannelHandler#handlerAdded(ChannelHandlerContext)}
* nor {@link ChannelHandler#handlerRemoved(ChannelHandlerContext)} was called.
*/
private static final int INIT = 0;
private final DefaultChannelPipeline pipeline;
private final String name;
private final boolean ordered;
private final int executionMask;
// Will be set to null if no child executor should be used, otherwise it will be set to the
// child executor.
final EventExecutor childExecutor;
// Cache the concrete value for the executor() method. This method is in the hot-path,
// and it's a profitable optimisation to avoid as many dependent-loads as possible.
// It does not need to be volatile, because it's always the same value for a given context,
// within the lifetime of its registration with an event loop, and deregistering will clear it.
EventExecutor contextExecutor;
private ChannelFuture succeededFuture;
// Lazily instantiated tasks used to trigger events to a handler with different executor.
// There is no need to make this volatile as at worse it will just create a few more instances then needed.
private Tasks invokeTasks;
private volatile int handlerState = INIT;
AbstractChannelHandlerContext(DefaultChannelPipeline pipeline, EventExecutor executor,
String name, Class<? extends ChannelHandler> handlerClass) {
this.name = ObjectUtil.checkNotNull(name, "name");
this.pipeline = pipeline;
childExecutor = executor;
executionMask = mask(handlerClass);
// Its ordered if its driven by the EventLoop or the given Executor is an instanceof OrderedEventExecutor.
ordered = executor == null || executor instanceof OrderedEventExecutor;
}
@Override
public Channel channel() {
return pipeline.channel();
}
@Override
public ChannelPipeline pipeline() {
return pipeline;
}
@Override
public ByteBufAllocator alloc() {
return channel().config().getAllocator();
}
@Override
public EventExecutor executor() {
EventExecutor ex = contextExecutor;
if (ex == null) {
contextExecutor = ex = childExecutor != null ? childExecutor : channel().eventLoop();
}
return ex;
}
Source
Frequently Asked Questions
What is the AbstractChannelHandlerContext class?
AbstractChannelHandlerContext is a class in the netty codebase, defined in transport/src/main/java/io/netty/channel/AbstractChannelHandlerContext.java.
Where is AbstractChannelHandlerContext defined?
AbstractChannelHandlerContext is defined in transport/src/main/java/io/netty/channel/AbstractChannelHandlerContext.java at line 60.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free