Home / Class/ CombinedChannelDuplexHandler Class — netty Architecture

CombinedChannelDuplexHandler Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  d9e90966_2763_e0d8_7a2c_c3339937a5a7["CombinedChannelDuplexHandler"]
  e7c03ebc_97b9_cfab_a4d7_aa767e667049["CombinedChannelDuplexHandler.java"]
  d9e90966_2763_e0d8_7a2c_c3339937a5a7 -->|defined in| e7c03ebc_97b9_cfab_a4d7_aa767e667049
  95b0b7cf_2953_288e_c8c3_4ade817efa53["CombinedChannelDuplexHandler()"]
  d9e90966_2763_e0d8_7a2c_c3339937a5a7 -->|method| 95b0b7cf_2953_288e_c8c3_4ade817efa53
  26381b7a_54f3_93c6_3580_82181da58ae7["init()"]
  d9e90966_2763_e0d8_7a2c_c3339937a5a7 -->|method| 26381b7a_54f3_93c6_3580_82181da58ae7
  c829476f_9743_1640_1764_a127fa4e13a8["validate()"]
  d9e90966_2763_e0d8_7a2c_c3339937a5a7 -->|method| c829476f_9743_1640_1764_a127fa4e13a8
  9eec7e1b_353f_4e0c_c1cb_7bba41429372["I()"]
  d9e90966_2763_e0d8_7a2c_c3339937a5a7 -->|method| 9eec7e1b_353f_4e0c_c1cb_7bba41429372
  82e8ccde_a3a8_4b62_6af2_77ae2b1a3585["O()"]
  d9e90966_2763_e0d8_7a2c_c3339937a5a7 -->|method| 82e8ccde_a3a8_4b62_6af2_77ae2b1a3585
  f50c2b49_5914_17c1_738d_5a5705b50a36["checkAdded()"]
  d9e90966_2763_e0d8_7a2c_c3339937a5a7 -->|method| f50c2b49_5914_17c1_738d_5a5705b50a36
  96ae33ed_29ae_f046_79a9_09fb0de64312["removeInboundHandler()"]
  d9e90966_2763_e0d8_7a2c_c3339937a5a7 -->|method| 96ae33ed_29ae_f046_79a9_09fb0de64312
  6c1d8b66_6d65_d3a4_8c9a_0215caab624e["removeOutboundHandler()"]
  d9e90966_2763_e0d8_7a2c_c3339937a5a7 -->|method| 6c1d8b66_6d65_d3a4_8c9a_0215caab624e
  3922501c_89d9_9315_87b2_3d95db47dd42["handlerAdded()"]
  d9e90966_2763_e0d8_7a2c_c3339937a5a7 -->|method| 3922501c_89d9_9315_87b2_3d95db47dd42
  7ec31b3b_e62c_5d37_2c5b_3e6775765e69["handlerRemoved()"]
  d9e90966_2763_e0d8_7a2c_c3339937a5a7 -->|method| 7ec31b3b_e62c_5d37_2c5b_3e6775765e69
  11f24101_c183_2cdc_c26d_ad670173f499["channelRegistered()"]
  d9e90966_2763_e0d8_7a2c_c3339937a5a7 -->|method| 11f24101_c183_2cdc_c26d_ad670173f499
  213237dc_9bbe_862d_9b76_90805a8e130a["channelUnregistered()"]
  d9e90966_2763_e0d8_7a2c_c3339937a5a7 -->|method| 213237dc_9bbe_862d_9b76_90805a8e130a
  8c1e4a50_b700_4b15_11f6_83a0f4d7fb0d["channelActive()"]
  d9e90966_2763_e0d8_7a2c_c3339937a5a7 -->|method| 8c1e4a50_b700_4b15_11f6_83a0f4d7fb0d

Relationship Graph

Source Code

transport/src/main/java/io/netty/channel/CombinedChannelDuplexHandler.java lines 31–614

public class CombinedChannelDuplexHandler<I extends ChannelInboundHandler, O extends ChannelOutboundHandler>
        extends ChannelDuplexHandler {

    private static final InternalLogger logger = InternalLoggerFactory.getInstance(CombinedChannelDuplexHandler.class);

    private DelegatingChannelHandlerContext inboundCtx;
    private DelegatingChannelHandlerContext outboundCtx;
    private volatile boolean handlerAdded;

    private I inboundHandler;
    private O outboundHandler;

    /**
     * Creates a new uninitialized instance. A class that extends this handler must invoke
     * {@link #init(ChannelInboundHandler, ChannelOutboundHandler)} before adding this handler into a
     * {@link ChannelPipeline}.
     */
    protected CombinedChannelDuplexHandler() {
        ensureNotSharable();
    }

    /**
     * Creates a new instance that combines the specified two handlers into one.
     */
    public CombinedChannelDuplexHandler(I inboundHandler, O outboundHandler) {
        ensureNotSharable();
        init(inboundHandler, outboundHandler);
    }

    /**
     * Initialized this handler with the specified handlers.
     *
     * @throws IllegalStateException if this handler was not constructed via the default constructor or
     *                               if this handler does not implement all required handler interfaces
     * @throws IllegalArgumentException if the specified handlers cannot be combined into one due to a conflict
     *                                  in the type hierarchy
     */
    protected final void init(I inboundHandler, O outboundHandler) {
        validate(inboundHandler, outboundHandler);
        this.inboundHandler = inboundHandler;
        this.outboundHandler = outboundHandler;
    }

    private void validate(I inboundHandler, O outboundHandler) {
        if (this.inboundHandler != null) {
            throw new IllegalStateException(
                    "init() can not be invoked if " + CombinedChannelDuplexHandler.class.getSimpleName() +
                            " was constructed with non-default constructor.");
        }

        ObjectUtil.checkNotNull(inboundHandler, "inboundHandler");
        ObjectUtil.checkNotNull(outboundHandler, "outboundHandler");

        if (inboundHandler instanceof ChannelOutboundHandler) {
            throw new IllegalArgumentException(
                    "inboundHandler must not implement " +
                    ChannelOutboundHandler.class.getSimpleName() + " to get combined.");
        }
        if (outboundHandler instanceof ChannelInboundHandler) {
            throw new IllegalArgumentException(
                    "outboundHandler must not implement " +
                    ChannelInboundHandler.class.getSimpleName() + " to get combined.");
        }
    }

    protected final I inboundHandler() {
        return inboundHandler;
    }

    protected final O outboundHandler() {
        return outboundHandler;
    }

    private void checkAdded() {
        if (!handlerAdded) {
            throw new IllegalStateException("handler not added to pipeline yet");
        }
    }

    /**
     * Removes the {@link ChannelInboundHandler} that was combined in this {@link CombinedChannelDuplexHandler}.

Frequently Asked Questions

What is the CombinedChannelDuplexHandler class?
CombinedChannelDuplexHandler is a class in the netty codebase, defined in transport/src/main/java/io/netty/channel/CombinedChannelDuplexHandler.java.
Where is CombinedChannelDuplexHandler defined?
CombinedChannelDuplexHandler is defined in transport/src/main/java/io/netty/channel/CombinedChannelDuplexHandler.java at line 31.

Analyze Your Own Codebase

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

Try Supermodel Free