ChannelPipeline在Netty中是用来处理请求的责任链,默认实现是DefaultChannelPipeline,其构造方法如下:
1 private final Channel channel; 2 private final ChannelFuture succeededFuture; 3 private final VoidChannelPromise voidPromise; 4 final AbstractChannelHandlerContext head; 5 final AbstractChannelHandlerContext tail; 6 7 protected DefaultChannelPipeline(Channel channel) { 8 this.channel = (Channel)ObjectUtil.checkNotNull(channel, "channel"); 9 this.succeededFuture = new SucceededChannelFuture(channel, (EventExecutor)null); 10 this.voidPromise = new VoidChannelPromise(channel, true); 11 this.tail = new DefaultChannelPipeline.TailContext(this); 12 this.head = new DefaultChannelPipeline.HeadContext(this); 13 this.head.next = this.tail; 14 this.tail.prev = this.head; 15 }