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 io.netty.buffer.ByteBuf;
18  import io.netty.channel.ChannelHandlerContext;
19  import io.netty.util.internal.UnstableApi;
20  
21  /**
22   * This class brings {@link Http2Connection.Listener} and {@link Http2FrameListener} together to provide
23   * NOOP implementation so inheriting classes can selectively choose which methods to override.
24   */
25  @UnstableApi
26  public class Http2EventAdapter implements Http2Connection.Listener, Http2FrameListener {
27      @Override
28      public int onDataRead(ChannelHandlerContext ctx, int streamId, ByteBuf data, int padding, boolean endOfStream)
29              throws Http2Exception {
30          return data.readableBytes() + padding;
31      }
32  
33      @Override
34      public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int padding,
35              boolean endStream) throws Http2Exception {
36      }
37  
38      @Override
39      public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int streamDependency,
40              short weight, boolean exclusive, int padding, boolean endStream) throws Http2Exception {
41      }
42  
43      @Override
44      public void onPriorityRead(ChannelHandlerContext ctx, int streamId, int streamDependency, short weight,
45              boolean exclusive) throws Http2Exception {
46      }
47  
48      @Override
49      public void onRstStreamRead(ChannelHandlerContext ctx, int streamId, long errorCode) throws Http2Exception {
50      }
51  
52      @Override
53      public void onSettingsAckRead(ChannelHandlerContext ctx) throws Http2Exception {
54      }
55  
56      @Override
57      public void onSettingsRead(ChannelHandlerContext ctx, Http2Settings settings) throws Http2Exception {
58      }
59  
60      @Override
61      public void onPingRead(ChannelHandlerContext ctx, long data) throws Http2Exception {
62      }
63  
64      @Override
65      public void onPingAckRead(ChannelHandlerContext ctx, long data) throws Http2Exception {
66      }
67  
68      @Override
69      public void onPushPromiseRead(ChannelHandlerContext ctx, int streamId, int promisedStreamId,
70              Http2Headers headers, int padding) throws Http2Exception {
71      }
72  
73      @Override
74      public void onGoAwayRead(ChannelHandlerContext ctx, int lastStreamId, long errorCode, ByteBuf debugData)
75              throws Http2Exception {
76      }
77  
78      @Override
79      public void onWindowUpdateRead(ChannelHandlerContext ctx, int streamId, int windowSizeIncrement)
80              throws Http2Exception {
81      }
82  
83      @Override
84      public void onUnknownFrame(ChannelHandlerContext ctx, byte frameType, int streamId, Http2Flags flags,
85              ByteBuf payload) throws Http2Exception {
86      }
87  
88      @Override
89      public void onStreamAdded(Http2Stream stream) {
90      }
91  
92      @Override
93      public void onStreamActive(Http2Stream stream) {
94      }
95  
96      @Override
97      public void onStreamHalfClosed(Http2Stream stream) {
98      }
99  
100     @Override
101     public void onStreamClosed(Http2Stream stream) {
102     }
103 
104     @Override
105     public void onStreamRemoved(Http2Stream stream) {
106     }
107 
108     @Override
109     public void onGoAwaySent(int lastStreamId, long errorCode, ByteBuf debugData) {
110     }
111 
112     @Override
113     public void onGoAwayReceived(int lastStreamId, long errorCode, ByteBuf debugData) {
114     }
115 }