Home / Class/ LastInboundHandler Class — netty Architecture

LastInboundHandler Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  c6d516e7_31d1_41fe_00af_40df976f9cda["LastInboundHandler"]
  fa6e0dfb_fe28_5c07_bc0a_88d819f51a51["LastInboundHandler.java"]
  c6d516e7_31d1_41fe_00af_40df976f9cda -->|defined in| fa6e0dfb_fe28_5c07_bc0a_88d819f51a51
  04ed7687_8cb9_e326_a65e_01d93c90dcb1["noopConsumer()"]
  c6d516e7_31d1_41fe_00af_40df976f9cda -->|method| 04ed7687_8cb9_e326_a65e_01d93c90dcb1
  9104a1e2_36b1_03ee_e726_d0ebcda992d0["LastInboundHandler()"]
  c6d516e7_31d1_41fe_00af_40df976f9cda -->|method| 9104a1e2_36b1_03ee_e726_d0ebcda992d0
  64852d68_f3c3_af7e_87d9_b76a431dceb9["handlerAdded()"]
  c6d516e7_31d1_41fe_00af_40df976f9cda -->|method| 64852d68_f3c3_af7e_87d9_b76a431dceb9
  f373006b_d655_ff76_ccd7_cf6ae9d60277["channelActive()"]
  c6d516e7_31d1_41fe_00af_40df976f9cda -->|method| f373006b_d655_ff76_ccd7_cf6ae9d60277
  efcf7cf2_4f47_cb50_73bd_b8566ec6a73f["isChannelActive()"]
  c6d516e7_31d1_41fe_00af_40df976f9cda -->|method| efcf7cf2_4f47_cb50_73bd_b8566ec6a73f
  8d97074b_f7ce_94c6_b0ec_b2dc6e3bf2fd["String()"]
  c6d516e7_31d1_41fe_00af_40df976f9cda -->|method| 8d97074b_f7ce_94c6_b0ec_b2dc6e3bf2fd
  7b0a3dde_fcce_1979_486b_bbd61c3ac897["channelInactive()"]
  c6d516e7_31d1_41fe_00af_40df976f9cda -->|method| 7b0a3dde_fcce_1979_486b_bbd61c3ac897
  457c9fbb_33ed_012b_6d66_1bad32f4e5b9["channelWritabilityChanged()"]
  c6d516e7_31d1_41fe_00af_40df976f9cda -->|method| 457c9fbb_33ed_012b_6d66_1bad32f4e5b9
  acb4f623_7224_bf57_3ae5_41f8d9be6ff9["channelRead()"]
  c6d516e7_31d1_41fe_00af_40df976f9cda -->|method| acb4f623_7224_bf57_3ae5_41f8d9be6ff9
  67645cf1_8412_be76_b134_4cb4b100c92d["channelReadComplete()"]
  c6d516e7_31d1_41fe_00af_40df976f9cda -->|method| 67645cf1_8412_be76_b134_4cb4b100c92d
  47951c5f_094c_9348_86c5_56bd48e5c7e7["userEventTriggered()"]
  c6d516e7_31d1_41fe_00af_40df976f9cda -->|method| 47951c5f_094c_9348_86c5_56bd48e5c7e7
  3e53b03d_e097_7e31_4a0e_1f51698f4e68["exceptionCaught()"]
  c6d516e7_31d1_41fe_00af_40df976f9cda -->|method| 3e53b03d_e097_7e31_4a0e_1f51698f4e68
  63f859a7_10d5_7dd6_6091_ff2387c03b75["checkException()"]
  c6d516e7_31d1_41fe_00af_40df976f9cda -->|method| 63f859a7_10d5_7dd6_6091_ff2387c03b75

Relationship Graph

Source Code

codec-http2/src/test/java/io/netty/handler/codec/http2/LastInboundHandler.java lines 36–222

public class LastInboundHandler extends ChannelDuplexHandler {
    private final List<Object> queue = new ArrayList<Object>();
    private final Consumer<ChannelHandlerContext> channelReadCompleteConsumer;
    private Throwable lastException;
    private ChannelHandlerContext ctx;
    private boolean channelActive;
    private String writabilityStates = "";

    // TODO(scott): use JDK 8's Consumer
    public interface Consumer<T> {
        void accept(T obj);
    }

    private static final Consumer<Object> NOOP_CONSUMER = new Consumer<Object>() {
        @Override
        public void accept(Object obj) {
        }
    };

    @SuppressWarnings("unchecked")
    public static <T> Consumer<T> noopConsumer() {
        return (Consumer<T>) NOOP_CONSUMER;
    }

    public LastInboundHandler() {
        this(LastInboundHandler.<ChannelHandlerContext>noopConsumer());
    }

    public LastInboundHandler(Consumer<ChannelHandlerContext> channelReadCompleteConsumer) {
        this.channelReadCompleteConsumer = checkNotNull(channelReadCompleteConsumer, "channelReadCompleteConsumer");
    }

    @Override
    public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
        super.handlerAdded(ctx);
        this.ctx = ctx;
    }

    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        if (channelActive) {
            throw new IllegalStateException("channelActive may only be fired once.");
        }
        channelActive = true;
        super.channelActive(ctx);
    }

    public boolean isChannelActive() {
        return channelActive;
    }

    public String writabilityStates() {
        return writabilityStates;
    }

    @Override
    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
        if (!channelActive) {
            throw new IllegalStateException("channelInactive may only be fired once after channelActive.");
        }
        channelActive = false;
        super.channelInactive(ctx);
    }

    @Override
    public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception {
        if ("".equals(writabilityStates)) {
            writabilityStates = String.valueOf(ctx.channel().isWritable());
        } else {
            writabilityStates += "," + ctx.channel().isWritable();
        }
        super.channelWritabilityChanged(ctx);
    }

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        queue.add(msg);
    }

    @Override
    public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {

Frequently Asked Questions

What is the LastInboundHandler class?
LastInboundHandler is a class in the netty codebase, defined in codec-http2/src/test/java/io/netty/handler/codec/http2/LastInboundHandler.java.
Where is LastInboundHandler defined?
LastInboundHandler is defined in codec-http2/src/test/java/io/netty/handler/codec/http2/LastInboundHandler.java at line 36.

Analyze Your Own Codebase

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

Try Supermodel Free