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
{@Override
public void handleDownstream(ChannelHandlerContext
ctx,ChannelEvent
e) 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 ChannelDownstreamHandler
ctx
- the context object for this handlere
- the downstream event to process or interceptException
public void writeRequested(ChannelHandlerContext ctx, MessageEvent e) throws Exception
Channel.write(Object)
is called.Exception
public void bindRequested(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception
Channel.bind(SocketAddress)
was called.Exception
public void connectRequested(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception
Channel.connect(SocketAddress)
was called.Exception
public void setInterestOpsRequested(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception
Channel.setInterestOps(int)
was called.Exception
public void disconnectRequested(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception
Channel.disconnect()
was called.Exception
public void unbindRequested(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception
Channel.unbind()
was called.Exception
public void closeRequested(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception
Channel.close()
was called.Exception
Copyright © 2008-2013 The Netty Project. All Rights Reserved.