Class ChannelInitializer<C extends Channel>

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelInitializer<C>
Type Parameters:
C - A sub-type of Channel
All Implemented Interfaces:
ChannelHandler, ChannelInboundHandler
Direct Known Subclasses:
Http3PushStreamClientInitializer, Http3PushStreamServerInitializer, Http3RequestStreamInitializer

@Sharable public abstract class ChannelInitializer<C extends Channel> extends ChannelInboundHandlerAdapter
A special ChannelInboundHandler which offers an easy way to initialize a Channel once it was registered to its EventLoop. Implementations are most often used in the context of AbstractBootstrap.handler(ChannelHandler) , AbstractBootstrap.handler(ChannelHandler) and ServerBootstrap.childHandler(ChannelHandler) to setup the ChannelPipeline of a Channel.
public class MyChannelInitializer extends ChannelInitializer {
 public void initChannel(Channel channel) {
 channel.pipeline().addLast("myHandler", new MyHandler());
 }
}
ServerBootstrap bootstrap = ...;
...
bootstrap.childHandler(new MyChannelInitializer());
...
Be aware that this class is marked as ChannelHandler.Sharable and so the implementation must be safe to be re-used.