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