查看本类的 API文档回源码主页即时通讯网 - 即时通讯开发者社区!
1   /*
2    * Copyright 2015 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License, version 2.0 (the
5    * "License"); you may not use this file except in compliance with the License. You may obtain a
6    * copy of the License at:
7    *
8    * https://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software distributed under the License
11   * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing permissions and limitations under
13   * the License.
14   */
15  package io.netty.handler.codec.http2;
16  
17  import io.netty.buffer.ByteBuf;
18  import io.netty.channel.ChannelFuture;
19  import io.netty.channel.ChannelHandlerContext;
20  import io.netty.channel.ChannelPromise;
21  import io.netty.util.internal.UnstableApi;
22  
23  import static io.netty.util.internal.ObjectUtil.checkNotNull;
24  
25  /**
26   * Decorator around another {@link Http2FrameWriter} instance.
27   */
28  @UnstableApi
29  public class DecoratingHttp2FrameWriter implements Http2FrameWriter {
30      private final Http2FrameWriter delegate;
31  
32      public DecoratingHttp2FrameWriter(Http2FrameWriter delegate) {
33          this.delegate = checkNotNull(delegate, "delegate");
34      }
35  
36      @Override
37      public ChannelFuture writeData(ChannelHandlerContext ctx, int streamId, ByteBuf data, int padding,
38                                     boolean endStream, ChannelPromise promise) {
39          return delegate.writeData(ctx, streamId, data, padding, endStream, promise);
40      }
41  
42      @Override
43      public ChannelFuture writeHeaders(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int padding,
44                                        boolean endStream, ChannelPromise promise) {
45          return delegate.writeHeaders(ctx, streamId, headers, padding, endStream, promise);
46      }
47  
48      @Override
49      public ChannelFuture writeHeaders(ChannelHandlerContext ctx, int streamId, Http2Headers headers,
50                                        int streamDependency, short weight, boolean exclusive, int padding,
51                                        boolean endStream, ChannelPromise promise) {
52          return delegate
53                  .writeHeaders(ctx, streamId, headers, streamDependency, weight, exclusive, padding, endStream, promise);
54      }
55  
56      @Override
57      public ChannelFuture writePriority(ChannelHandlerContext ctx, int streamId, int streamDependency, short weight,
58                                         boolean exclusive, ChannelPromise promise) {
59          return delegate.writePriority(ctx, streamId, streamDependency, weight, exclusive, promise);
60      }
61  
62      @Override
63      public ChannelFuture writeRstStream(ChannelHandlerContext ctx, int streamId, long errorCode,
64                                          ChannelPromise promise) {
65          return delegate.writeRstStream(ctx, streamId, errorCode, promise);
66      }
67  
68      @Override
69      public ChannelFuture writeSettings(ChannelHandlerContext ctx, Http2Settings settings, ChannelPromise promise) {
70          return delegate.writeSettings(ctx, settings, promise);
71      }
72  
73      @Override
74      public ChannelFuture writeSettingsAck(ChannelHandlerContext ctx, ChannelPromise promise) {
75          return delegate.writeSettingsAck(ctx, promise);
76      }
77  
78      @Override
79      public ChannelFuture writePing(ChannelHandlerContext ctx, boolean ack, long data, ChannelPromise promise) {
80          return delegate.writePing(ctx, ack, data, promise);
81      }
82  
83      @Override
84      public ChannelFuture writePushPromise(ChannelHandlerContext ctx, int streamId, int promisedStreamId,
85                                            Http2Headers headers, int padding, ChannelPromise promise) {
86          return delegate.writePushPromise(ctx, streamId, promisedStreamId, headers, padding, promise);
87      }
88  
89      @Override
90      public ChannelFuture writeGoAway(ChannelHandlerContext ctx, int lastStreamId, long errorCode, ByteBuf debugData,
91                                       ChannelPromise promise) {
92          return delegate.writeGoAway(ctx, lastStreamId, errorCode, debugData, promise);
93      }
94  
95      @Override
96      public ChannelFuture writeWindowUpdate(ChannelHandlerContext ctx, int streamId, int windowSizeIncrement,
97                                             ChannelPromise promise) {
98          return delegate.writeWindowUpdate(ctx, streamId, windowSizeIncrement, promise);
99      }
100 
101     @Override
102     public ChannelFuture writeFrame(ChannelHandlerContext ctx, byte frameType, int streamId, Http2Flags flags,
103                                     ByteBuf payload, ChannelPromise promise) {
104         return delegate.writeFrame(ctx, frameType, streamId, flags, payload, promise);
105     }
106 
107     @Override
108     public Configuration configuration() {
109         return delegate.configuration();
110     }
111 
112     @Override
113     public void close() {
114         delegate.close();
115     }
116 }