public class SimpleChannelDownstreamHandler extends java.lang.Object implements ChannelDownstreamHandler
ChannelDownstreamHandler which provides an individual handler
method for each event type. This handler down-casts the received downstream
event into more meaningful sub-type event and calls an appropriate handler
method with the down-cast event. The names of the methods starts with the
name of the operation and ends with "Requested"
(e.g. writeRequested.)
Please use SimpleChannelHandler if you need to implement both
ChannelUpstreamHandler and ChannelDownstreamHandler.
handleDownstream method
You can override the handleDownstream
method just like overriding an ordinary Java method. Please make sure to
call super.handleDownstream() so that other handler methods are
invoked properly:
public class MyChannelHandler extendsSimpleChannelDownstreamHandler{@Overridepublic void handleDownstream(ChannelHandlerContextctx,ChannelEvente) throws Exception { // Log all channel state changes. if (e instanceofMessageEvent) { logger.info("Writing:: " + e); } super.handleDownstream(ctx, e); } }
Caution:
Use the *Later(..) methods of the Channels class if you want to send an upstream event
from a ChannelDownstreamHandler otherwise you may run into threading issues.
ChannelHandler.Sharable| 构造器和说明 |
|---|
SimpleChannelDownstreamHandler() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
bindRequested(ChannelHandlerContext ctx,
ChannelStateEvent e)
Invoked when
Channel.bind(SocketAddress) was called. |
void |
closeRequested(ChannelHandlerContext ctx,
ChannelStateEvent e)
Invoked when
Channel.close() was called. |
void |
connectRequested(ChannelHandlerContext ctx,
ChannelStateEvent e)
Invoked when
Channel.connect(SocketAddress) was called. |
void |
disconnectRequested(ChannelHandlerContext ctx,
ChannelStateEvent e)
Invoked when
Channel.disconnect() was called. |
void |
handleDownstream(ChannelHandlerContext ctx,
ChannelEvent e)
Handles the specified downstream event.
|
void |
setInterestOpsRequested(ChannelHandlerContext ctx,
ChannelStateEvent e)
Invoked when
Channel.setInterestOps(int) was called. |
void |
unbindRequested(ChannelHandlerContext ctx,
ChannelStateEvent e)
Invoked when
Channel.unbind() was called. |
void |
writeRequested(ChannelHandlerContext ctx,
MessageEvent e)
Invoked when
Channel.write(Object) is called. |
public void handleDownstream(ChannelHandlerContext ctx, ChannelEvent e) throws java.lang.Exception
handleDownstream 在接口中 ChannelDownstreamHandlerctx - the context object for this handlere - the downstream event to process or interceptjava.lang.Exceptionpublic void writeRequested(ChannelHandlerContext ctx, MessageEvent e) throws java.lang.Exception
Channel.write(Object) is called.java.lang.Exceptionpublic void bindRequested(ChannelHandlerContext ctx, ChannelStateEvent e) throws java.lang.Exception
Channel.bind(SocketAddress) was called.java.lang.Exceptionpublic void connectRequested(ChannelHandlerContext ctx, ChannelStateEvent e) throws java.lang.Exception
Channel.connect(SocketAddress) was called.java.lang.Exceptionpublic void setInterestOpsRequested(ChannelHandlerContext ctx, ChannelStateEvent e) throws java.lang.Exception
Channel.setInterestOps(int) was called.java.lang.Exceptionpublic void disconnectRequested(ChannelHandlerContext ctx, ChannelStateEvent e) throws java.lang.Exception
Channel.disconnect() was called.java.lang.Exceptionpublic void unbindRequested(ChannelHandlerContext ctx, ChannelStateEvent e) throws java.lang.Exception
Channel.unbind() was called.java.lang.Exceptionpublic void closeRequested(ChannelHandlerContext ctx, ChannelStateEvent e) throws java.lang.Exception
Channel.close() was called.java.lang.Exception