org.jboss.netty.channel
类 SimpleChannelDownstreamHandler

java.lang.Object
  继承者 org.jboss.netty.channel.SimpleChannelDownstreamHandler
所有已实现的接口:
ChannelDownstreamHandler, ChannelHandler
直接已知子类:
WriteTimeoutHandler

public class SimpleChannelDownstreamHandler
extends java.lang.Object
implements ChannelDownstreamHandler

为每个事件类型提供单独处理方法的ChannelDownstreamHandler .处理器会把接收到的下游事件转型为更有意义的子类型事件并调用转型事件的适当方法.方法名字的开头使用操作的名字并以"Requested" 结尾(如. writeRequested.)

如果你需要同时实现ChannelUpstreamHandlerChannelDownstreamHandler,请使用 SimpleChannelHandler

重写handleDownstream方法

你可以像重写一般Java方法一样重写 handleDownstream 方法. 请确保调用handleDownstream()以便其他处理器的方法可以被正确的调用:

 public class MyChannelHandler extends SimpleChannelDownstreamHandler {
 
     @Override
     public void handleDownstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception {
 
         // 记录所有通道状态改变.
         if (e instanceof MessageEvent) {
             logger.info("Writing:: " + e);
         }
 
         super.handleDownstream(ctx, e);
     }
 }
 


嵌套类摘要
 
从接口 org.jboss.netty.channel.ChannelHandler 继承的嵌套类/接口
ChannelHandler.Sharable
 
构造方法摘要
SimpleChannelDownstreamHandler()
          创建一个实例.
 
方法摘要
 void bindRequested(ChannelHandlerContext ctx, ChannelStateEvent e)
          当Channel.bind(SocketAddress)被调用时调用.
 void closeRequested(ChannelHandlerContext ctx, ChannelStateEvent e)
          当Channel.close()被调用时调用.
 void connectRequested(ChannelHandlerContext ctx, ChannelStateEvent e)
          当Channel.connect(SocketAddress)被调用时调用.
 void disconnectRequested(ChannelHandlerContext ctx, ChannelStateEvent e)
          当Channel.disconnect()被调用时调用.
 void handleDownstream(ChannelHandlerContext ctx, ChannelEvent e)
          处理指定的下游事件.
 void setInterestOpsRequested(ChannelHandlerContext ctx, ChannelStateEvent e)
          当Channel.setInterestOps(int)被调用时调用.
 void unbindRequested(ChannelHandlerContext ctx, ChannelStateEvent e)
          当Channel.unbind()被调用时调用.
 void writeRequested(ChannelHandlerContext ctx, MessageEvent e)
          当Channel.write(Object)被调用时调用.
 
从类 java.lang.Object 继承的方法
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

SimpleChannelDownstreamHandler

public SimpleChannelDownstreamHandler()
创建一个实例.

方法详细信息

handleDownstream

public void handleDownstream(ChannelHandlerContext ctx,
                             ChannelEvent e)
                      throws java.lang.Exception
处理指定的下游事件. 把接收到的下游事件转型为更有意义的子类型事件并调用转型事件的适当方法.

指定者:
接口 ChannelDownstreamHandler 中的 handleDownstream
参数:
ctx - 处理器的上下文对象
e - 要处理或拦截的事件
抛出:
java.lang.Exception

writeRequested

public void writeRequested(ChannelHandlerContext ctx,
                           MessageEvent e)
                    throws java.lang.Exception
Channel.write(Object)被调用时调用.

抛出:
java.lang.Exception

bindRequested

public void bindRequested(ChannelHandlerContext ctx,
                          ChannelStateEvent e)
                   throws java.lang.Exception
Channel.bind(SocketAddress)被调用时调用.

抛出:
java.lang.Exception

connectRequested

public void connectRequested(ChannelHandlerContext ctx,
                             ChannelStateEvent e)
                      throws java.lang.Exception
Channel.connect(SocketAddress)被调用时调用.

抛出:
java.lang.Exception

setInterestOpsRequested

public void setInterestOpsRequested(ChannelHandlerContext ctx,
                                    ChannelStateEvent e)
                             throws java.lang.Exception
Channel.setInterestOps(int)被调用时调用.

抛出:
java.lang.Exception

disconnectRequested

public void disconnectRequested(ChannelHandlerContext ctx,
                                ChannelStateEvent e)
                         throws java.lang.Exception
Channel.disconnect()被调用时调用.

抛出:
java.lang.Exception

unbindRequested

public void unbindRequested(ChannelHandlerContext ctx,
                            ChannelStateEvent e)
                     throws java.lang.Exception
Channel.unbind()被调用时调用.

抛出:
java.lang.Exception

closeRequested

public void closeRequested(ChannelHandlerContext ctx,
                           ChannelStateEvent e)
                    throws java.lang.Exception
Channel.close()被调用时调用.

抛出:
java.lang.Exception