Home / Class/ Http2ChannelDuplexHandler Class — netty Architecture

Http2ChannelDuplexHandler Class — netty Architecture

Architecture documentation for the Http2ChannelDuplexHandler class in Http2ChannelDuplexHandler.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  54f99180_cc75_9d7d_df61_637bf63d8deb["Http2ChannelDuplexHandler"]
  64619e33_7d37_3c33_19db_7ac214683149["Http2ChannelDuplexHandler.java"]
  54f99180_cc75_9d7d_df61_637bf63d8deb -->|defined in| 64619e33_7d37_3c33_19db_7ac214683149
  54a0f38f_4496_b1c4_7cd9_336f9610cf2b["handlerAdded()"]
  54f99180_cc75_9d7d_df61_637bf63d8deb -->|method| 54a0f38f_4496_b1c4_7cd9_336f9610cf2b
  284589ec_c632_9b00_9bf2_11b3daca10e6["handlerAdded0()"]
  54f99180_cc75_9d7d_df61_637bf63d8deb -->|method| 284589ec_c632_9b00_9bf2_11b3daca10e6
  14fcc70c_8a99_c4e4_d81b_1e945834b694["handlerRemoved()"]
  54f99180_cc75_9d7d_df61_637bf63d8deb -->|method| 14fcc70c_8a99_c4e4_d81b_1e945834b694
  3b2fca36_2910_d8dd_37a0_66ea0e04b871["handlerRemoved0()"]
  54f99180_cc75_9d7d_df61_637bf63d8deb -->|method| 3b2fca36_2910_d8dd_37a0_66ea0e04b871
  0f2d3e15_2661_8cd8_835f_c7510c35c89d["Http2FrameStream()"]
  54f99180_cc75_9d7d_df61_637bf63d8deb -->|method| 0f2d3e15_2661_8cd8_835f_c7510c35c89d
  bbb89022_b019_5b78_88a8_ba8d5838634c["forEachActiveStream()"]
  54f99180_cc75_9d7d_df61_637bf63d8deb -->|method| bbb89022_b019_5b78_88a8_ba8d5838634c
  96eeb87d_50f1_a2d9_0770_1446ea4ebc00["Http2FrameCodec()"]
  54f99180_cc75_9d7d_df61_637bf63d8deb -->|method| 96eeb87d_50f1_a2d9_0770_1446ea4ebc00

Relationship Graph

Source Code

codec-http2/src/main/java/io/netty/handler/codec/http2/Http2ChannelDuplexHandler.java lines 34–92

public abstract class Http2ChannelDuplexHandler extends ChannelDuplexHandler {

    private volatile Http2FrameCodec frameCodec;

    @Override
    public final void handlerAdded(ChannelHandlerContext ctx) throws Exception {
        frameCodec = requireHttp2FrameCodec(ctx);
        handlerAdded0(ctx);
    }

    protected void handlerAdded0(@SuppressWarnings("unused") ChannelHandlerContext ctx) throws Exception {
        // NOOP
    }

    @Override
    public final void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
        try {
            handlerRemoved0(ctx);
        } finally {
            frameCodec = null;
        }
    }

    protected void handlerRemoved0(@SuppressWarnings("unused") ChannelHandlerContext ctx) throws Exception {
        // NOOP
    }

    /**
     * Creates a new {@link Http2FrameStream} object.
     *
     * <p>This method is <em>thread-safe</em>.
     */
    public final Http2FrameStream newStream() {
        Http2FrameCodec codec = frameCodec;
        if (codec == null) {
            throw new IllegalStateException(StringUtil.simpleClassName(Http2FrameCodec.class) + " not found." +
                    " Has the handler been added to a pipeline?");
        }
        return codec.newStream();
    }

    /**
     * Allows to iterate over all currently active streams.
     *
     * <p>This method may only be called from the eventloop thread.
     */
    protected final void forEachActiveStream(Http2FrameStreamVisitor streamVisitor) throws Http2Exception {
        frameCodec.forEachActiveStream(streamVisitor);
    }

    private static Http2FrameCodec requireHttp2FrameCodec(ChannelHandlerContext ctx) {
        ChannelHandlerContext frameCodecCtx = ctx.pipeline().context(Http2FrameCodec.class);
        if (frameCodecCtx == null) {
            throw new IllegalArgumentException(Http2FrameCodec.class.getSimpleName()
                                               + " was not found in the channel pipeline.");
        }
        return (Http2FrameCodec) frameCodecCtx.handler();
    }
}

Frequently Asked Questions

What is the Http2ChannelDuplexHandler class?
Http2ChannelDuplexHandler is a class in the netty codebase, defined in codec-http2/src/main/java/io/netty/handler/codec/http2/Http2ChannelDuplexHandler.java.
Where is Http2ChannelDuplexHandler defined?
Http2ChannelDuplexHandler is defined in codec-http2/src/main/java/io/netty/handler/codec/http2/Http2ChannelDuplexHandler.java at line 34.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free