Class SimpleChannelUpstreamHandler

java.lang.Object
org.jboss.netty.channel.SimpleChannelUpstreamHandler
All Implemented Interfaces:
ChannelHandler, ChannelUpstreamHandler
Direct Known Subclasses:
AutobahnServerHandler, BlockingReadHandler, DiscardClientHandler, DiscardServerHandler, EchoClientHandler, EchoServerHandler, FactorialClientHandler, FactorialServerHandler, FrameDecoder, HexDumpProxyInboundHandler, HexDumpProxyInboundHandler.OutboundHandler, HttpChunkAggregator, HttpContentDecoder, HttpHelloWorldServerHandler, HttpSnoopClientHandler, HttpSnoopServerHandler, HttpStaticFileServerHandler, HttpTunnelingClientSocketChannel.ServletChannelHandler, HttpTunnelingServlet.OutboundConnectionHandler, HttpUploadClientHandler, HttpUploadServerHandler, IdleStateAwareChannelUpstreamHandler, IdleStateHandler, LocalTimeClientHandler, LocalTimeServerHandler, ObjectEchoClientHandler, ObjectEchoServerHandler, QuoteOfTheMomentClientHandler, QuoteOfTheMomentServerHandler, ReadTimeoutHandler, SecureChatClientHandler, SecureChatServerHandler, ServerBootstrap.Binder, SpdySessionHandler, TelnetClientHandler, TelnetServerHandler, UptimeClientHandler, WebSocketClientHandler, WebSocketServerHandler, WebSocketServerProtocolHandler, WebSocketServerProtocolHandshakeHandler

public class SimpleChannelUpstreamHandler extends Object implements ChannelUpstreamHandler
A ChannelUpstreamHandler which provides an individual handler method for each event type. This handler down-casts the received upstream event into more meaningful sub-type event and calls an appropriate handler method with the down-cast event. The names of the methods are identical to the upstream event names, as introduced in the ChannelEvent documentation.

Please use SimpleChannelHandler if you need to implement both ChannelUpstreamHandler and ChannelDownstreamHandler.

Overriding the handleUpstream method

You can override the handleUpstream method just like overriding an ordinary Java method. Please make sure to call super.handleUpstream() so that other handler methods are invoked properly:

public class MyChannelHandler extends SimpleChannelUpstreamHandler {

     @Override
     public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception {

         // Log all channel state changes.
         if (e instanceof ChannelStateEvent) {
             logger.info("Channel state changed: " + e);
         }

         super.handleUpstream(ctx, e);
     }
 }