Channel
ChannelHandler 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 Bootstrap#handler(ChannelHandler) ,
ServerBootstrap#handler(ChannelHandler) and ServerBootstrap#childHandler(ChannelHandler) to
setup the ChannelPipeline of a Channel.
public class MyChannelInitializer extendsBe aware that this class is marked asChannelInitializer{ public void initChannel(Channelchannel) { channel.pipeline().addLast("myHandler", new MyHandler()); } }ServerBootstrapbootstrap = ...; ... bootstrap.childHandler(new MyChannelInitializer()); ...
isSharable() and so the implementation must be safe to be re-used.
| Modifier and Type | Field and Description |
|---|---|
| private static final InternalLogger |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | channelExceptionCaught(ChannelHandlerContext ctx, Throwable cause)
Overrides default io. Throwable by logging and closing the Channel.
|
| public void | handlerAdded(ChannelHandlerContext ctx)
Overrides default io. ChannelHandler was added to the actual context and it's ready to handle events.
|
| protected abstract void | initChannel(C
the ch)Channel which was registered.This method will be called once the |
| public boolean | isSharable()
Overrides default io. true if this handler is sharable and thus can be added
to more than one ChannelPipeline.
|
| logger | back to summary |
|---|---|
| private static final InternalLogger logger | |
| ChannelInitializer | back to summary |
|---|---|
| public ChannelInitializer() | |
| channelExceptionCaught | back to summary |
|---|---|
| public void channelExceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception Overrides default io. Handle the
| |
| handlerAdded | back to summary |
|---|---|
| public void handlerAdded(ChannelHandlerContext ctx) throws Exception Overrides default io. Doc from io. Gets called after the
| |
| initChannel | back to summary |
|---|---|
| protected abstract void initChannel(C ch) throws Exception This method will be called once the
| |
| isSharable | back to summary |
|---|---|
| public boolean isSharable() Overrides default io. Doc from io. Returns
| |