View Javadoc
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  
22  import static io.netty.util.internal.ObjectUtil.checkNotNull;
23  
24  /**
25   * Decorator around another {@link Http2FrameWriter} instance.
26   */
27  public class DecoratingHttp2FrameWriter implements Http2FrameWriter {
28      private final Http2FrameWriter delegate;
29  
30      public DecoratingHttp2FrameWriter(Http2FrameWriter delegate) {
31          this.delegate = checkNotNull(delegate, "delegate");
32      }
33  
34      @Override
35      public ChannelFuture writeData(ChannelHandlerContext ctx, int streamId, ByteBuf data, int padding,
36                                     boolean endStream, ChannelPromise promise) {
37          return delegate.writeData(ctx, streamId, data, padding, endStream, promise);
38      }
39  
40      @Override
41      public ChannelFuture writeHeaders(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int padding,
42                                        boolean endStream, ChannelPromise promise) {
43          return delegate.writeHeaders(ctx, streamId, headers, padding, endStream, promise);
44      }
45  
46      @Override
47      public ChannelFuture writeHeaders(ChannelHandlerContext ctx, int streamId, Http2Headers headers,
48                                        int streamDependency, short weight, boolean exclusive, int padding,
49                                        boolean endStream, ChannelPromise promise) {
50          return delegate
51                  .writeHeaders(ctx, streamId, headers, streamDependency, weight, exclusive, padding, endStream, promise);
52      }
53  
54      @Override
55      public ChannelFuture writePriority(ChannelHandlerContext ctx, int streamId, int streamDependency, short weight,
56                                         boolean exclusive, ChannelPromise promise) {
57          return delegate.writePriority(ctx, streamId, streamDependency, weight, exclusive, promise);
58      }
59  
60      @Override
61      public ChannelFuture writeRstStream(ChannelHandlerContext ctx, int streamId, long errorCode,
62                                          ChannelPromise promise) {
63          return delegate.writeRstStream(ctx, streamId, errorCode, promise);
64      }
65  
66      @Override
67      public ChannelFuture writeSettings(ChannelHandlerContext ctx, Http2Settings settings, ChannelPromise promise) {
68          return delegate.writeSettings(ctx, settings, promise);
69      }
70  
71      @Override
72      public ChannelFuture writeSettingsAck(ChannelHandlerContext ctx, ChannelPromise promise) {
73          return delegate.writeSettingsAck(ctx, promise);
74      }
75  
76      @Override
77      public ChannelFuture writePing(ChannelHandlerContext ctx, boolean ack, long data, ChannelPromise promise) {
78          return delegate.writePing(ctx, ack, data, promise);
79      }
80  
81      @Override
82      public ChannelFuture writePushPromise(ChannelHandlerContext ctx, int streamId, int promisedStreamId,
83                                            Http2Headers headers, int padding, ChannelPromise promise) {
84          return delegate.writePushPromise(ctx, streamId, promisedStreamId, headers, padding, promise);
85      }
86  
87      @Override
88      public ChannelFuture writeGoAway(ChannelHandlerContext ctx, int lastStreamId, long errorCode, ByteBuf debugData,
89                                       ChannelPromise promise) {
90          return delegate.writeGoAway(ctx, lastStreamId, errorCode, debugData, promise);
91      }
92  
93      @Override
94      public ChannelFuture writeWindowUpdate(ChannelHandlerContext ctx, int streamId, int windowSizeIncrement,
95                                             ChannelPromise promise) {
96          return delegate.writeWindowUpdate(ctx, streamId, windowSizeIncrement, promise);
97      }
98  
99      @Override
100     public ChannelFuture writeFrame(ChannelHandlerContext ctx, byte frameType, int streamId, Http2Flags flags,
101                                     ByteBuf payload, ChannelPromise promise) {
102         return delegate.writeFrame(ctx, frameType, streamId, flags, payload, promise);
103     }
104 
105     @Override
106     public Configuration configuration() {
107         return delegate.configuration();
108     }
109 
110     @Override
111     public void close() {
112         delegate.close();
113     }
114 }