Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jboss.netty.channel
Class SimpleChannelDownstreamHandler

    java.lang.Object
      org.jboss.netty.channel.SimpleChannelDownstreamHandler

All Implemented Interfaces:
  ChannelDownstreamHandler, ChannelHandler

Direct Known Subclasses:
  WriteTimeoutHandler

    public class SimpleChannelDownstreamHandler

extends Object
implements ChannelDownstreamHandler

A `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`.

### Overriding the `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 extends SimpleChannelDownstreamHandler {

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

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

             super.handleDownstream(ctx, e);
         }
     }

Version:
  $Rev: 2122 $, $Date: 2010-02-02 11:00:04 +0900 (Tue, 02 Feb 2010) $
Author:
  The Netty Project, Trustin Lee

Nested Class Summary

Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
`ChannelHandler.Sharable`

Constructor Summary
`SimpleChannelDownstreamHandler()` Creates a new instance.

Method Summary
`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.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SimpleChannelDownstreamHandler

    public SimpleChannelDownstreamHandler()

  Creates a new instance.

Method Detail

### handleDownstream

    public void handleDownstream(ChannelHandlerContext ctx,
                                 ChannelEvent e)
                          throws Exception

  Handles the specified downstream event. Down-casts the received downstream event into more meaningful sub-type event and calls an appropriate handler method with the down-casted event.

  Specified by:
    `handleDownstream` in interface `ChannelDownstreamHandler`
  Parameters:
    `ctx` - the context object for this handler
    `e` - the downstream event to process or intercept
  Throws:
    `Exception`

### writeRequested

    public void writeRequested(ChannelHandlerContext ctx,
                               MessageEvent e)
                        throws Exception

  Invoked when `Channel.write(Object)` is called.

  Throws:
    `Exception`

### bindRequested

    public void bindRequested(ChannelHandlerContext ctx,
                              ChannelStateEvent e)
                       throws Exception

  Invoked when `Channel.bind(SocketAddress)` was called.

  Throws:
    `Exception`

### connectRequested

    public void connectRequested(ChannelHandlerContext ctx,
                                 ChannelStateEvent e)
                          throws Exception

  Invoked when `Channel.connect(SocketAddress)` was called.

  Throws:
    `Exception`

### setInterestOpsRequested

    public void setInterestOpsRequested(ChannelHandlerContext ctx,
                                        ChannelStateEvent e)
                                 throws Exception

  Invoked when `Channel.setInterestOps(int)` was called.

  Throws:
    `Exception`

### disconnectRequested

    public void disconnectRequested(ChannelHandlerContext ctx,
                                    ChannelStateEvent e)
                             throws Exception

  Invoked when `Channel.disconnect()` was called.

  Throws:
    `Exception`

### unbindRequested

    public void unbindRequested(ChannelHandlerContext ctx,
                                ChannelStateEvent e)
                         throws Exception

  Invoked when `Channel.unbind()` was called.

  Throws:
    `Exception`

### closeRequested

    public void closeRequested(ChannelHandlerContext ctx,
                               ChannelStateEvent e)
                        throws Exception

  Invoked when `Channel.close()` was called.

  Throws:
    `Exception`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008-2010 JBoss, a division of Red Hat, Inc.. All Rights Reserved.