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