View Javadoc
1   /*
2    * Copyright 2014 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.internal.UnstableApi;
20  
21  import static java.util.Objects.requireNonNull;
22  
23  /**
24   * Provides a decorator around a {@link Http2FrameListener} and delegates all method calls
25   */
26  @UnstableApi
27  public class Http2FrameListenerDecorator implements Http2FrameListener {
28      protected final Http2FrameListener listener;
29  
30      public Http2FrameListenerDecorator(Http2FrameListener listener) {
31          this.listener = requireNonNull(listener, "listener");
32      }
33  
34      @Override
35      public int onDataRead(ChannelHandlerContext ctx, int streamId, Buffer data, int padding, boolean endOfStream)
36              throws Http2Exception {
37          return listener.onDataRead(ctx, streamId, data, padding, endOfStream);
38      }
39  
40      @Override
41      public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int padding,
42              boolean endStream) throws Http2Exception {
43          listener.onHeadersRead(ctx, streamId, headers, padding, endStream);
44      }
45  
46      @Override
47      public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int streamDependency,
48              short weight, boolean exclusive, int padding, boolean endStream) throws Http2Exception {
49          listener.onHeadersRead(ctx, streamId, headers, streamDependency, weight, exclusive, padding, endStream);
50      }
51  
52      @Override
53      public void onPriorityRead(ChannelHandlerContext ctx, int streamId, int streamDependency, short weight,
54              boolean exclusive) throws Http2Exception {
55          listener.onPriorityRead(ctx, streamId, streamDependency, weight, exclusive);
56      }
57  
58      @Override
59      public void onRstStreamRead(ChannelHandlerContext ctx, int streamId, long errorCode) throws Http2Exception {
60          listener.onRstStreamRead(ctx, streamId, errorCode);
61      }
62  
63      @Override
64      public void onSettingsAckRead(ChannelHandlerContext ctx) throws Http2Exception {
65          listener.onSettingsAckRead(ctx);
66      }
67  
68      @Override
69      public void onSettingsRead(ChannelHandlerContext ctx, Http2Settings settings) throws Http2Exception {
70          listener.onSettingsRead(ctx, settings);
71      }
72  
73      @Override
74      public void onPingRead(ChannelHandlerContext ctx, long data) throws Http2Exception {
75          listener.onPingRead(ctx, data);
76      }
77  
78      @Override
79      public void onPingAckRead(ChannelHandlerContext ctx, long data) throws Http2Exception {
80          listener.onPingAckRead(ctx, data);
81      }
82  
83      @Override
84      public void onPushPromiseRead(ChannelHandlerContext ctx, int streamId, int promisedStreamId, Http2Headers headers,
85              int padding) throws Http2Exception {
86          listener.onPushPromiseRead(ctx, streamId, promisedStreamId, headers, padding);
87      }
88  
89      @Override
90      public void onGoAwayRead(ChannelHandlerContext ctx, int lastStreamId, long errorCode, Buffer debugData)
91              throws Http2Exception {
92          listener.onGoAwayRead(ctx, lastStreamId, errorCode, debugData);
93      }
94  
95      @Override
96      public void onWindowUpdateRead(ChannelHandlerContext ctx, int streamId, int windowSizeIncrement)
97              throws Http2Exception {
98          listener.onWindowUpdateRead(ctx, streamId, windowSizeIncrement);
99      }
100 
101     @Override
102     public void onUnknownFrame(ChannelHandlerContext ctx, byte frameType, int streamId, Http2Flags flags,
103                                Buffer payload) throws Http2Exception {
104         listener.onUnknownFrame(ctx, frameType, streamId, flags, payload);
105     }
106 }