
public class SimpleChannelDownstreamHandler extends 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| Constructor and Description |
|---|
SimpleChannelDownstreamHandler() |
| Modifier and Type | Method and Description |
|---|---|
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 Exception
handleDownstream in interface ChannelDownstreamHandlerctx - the context object for this handlere - the downstream event to process or interceptExceptionpublic void writeRequested(ChannelHandlerContext ctx, MessageEvent e) throws Exception
Channel.write(Object) is called.Exceptionpublic void bindRequested(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception
Channel.bind(SocketAddress) was called.Exceptionpublic void connectRequested(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception
Channel.connect(SocketAddress) was called.Exceptionpublic void setInterestOpsRequested(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception
Channel.setInterestOps(int) was called.Exceptionpublic void disconnectRequested(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception
Channel.disconnect() was called.Exceptionpublic void unbindRequested(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception
Channel.unbind() was called.Exceptionpublic void closeRequested(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception
Channel.close() was called.ExceptionCopyright © 2008-2013 The Netty Project. All Rights Reserved.