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