Java 类io.netty.handler.codec.ByteToMessageCodec 实例源码

项目:reactor-netty    文件:HttpOperations.java   
static void autoAddHttpExtractor(NettyContext c, String name, ChannelHandler
        handler){

    if (handler instanceof ByteToMessageDecoder
            || handler instanceof ByteToMessageCodec
            || handler instanceof CombinedChannelDuplexHandler) {
        String extractorName = name+"$extractor";

        if(c.channel().pipeline().context(extractorName) != null){
            return;
        }

        c.channel().pipeline().addBefore(name, extractorName, HTTP_EXTRACTOR);

        if(NettyContext.isPersistent(c.channel())){
            c.onClose(() -> c.removeHandler(extractorName));
        }

    }
}