Add handlers to channel.

@param ch the channel for adding handlers
@throws IOException
545837
public void addToChannel(Channel ch) throws IOException {
    ch.pipeline()
      .addFirst(ENCRYPTION_HANDLER_NAME, new EncryptionHandler(this))
      .addFirst(DECRYPTION_HANDLER_NAME, new DecryptionHandler(this));
  }
618863
public Token addToTrigger(Char ch) {
        trigger += ch.getValue();
        internTrigger = null;
        source += ch.getValue();
        return this;
    }
384259
final public void write(int ch)
  {
    try {
      _out.print((char) ch);
    } catch (IOException e) {
      log.log(Level.FINE, e.toString(), e);
    }
  }
328200
public Javalin addHandler(@NotNull HandlerType httpMethod, @NotNull String path, @NotNull Handler handler) {
        return addHandler(httpMethod, path, handler, new HashSet<>()); // no roles set for this route (open to everyone with default access manager)
    }
632917
public static void process(InputStream inputStream, StreamHandler handler) throws IOException {
    LOGGER.trace("process(InputStream, StreamHandler)");
    process(inputStream, handler, new byte[BUFFER_SIZE]);
  }
509565
public void addHandler(CacheMissHandler handler) {
		if(handler != null) {
			logger.debug("adding handler of class '{}'", handler.getClass());
			handlers.add(handler);
		}
	}
1391
@SuppressWarnings("unchecked")
    public <E> MessageHandler<? super E> addReceivedMessageHandler(Class<E> type,
            MessageHandler<? super E> handler) {
        receivedMessageHandlerCache.clear();
        return (MessageHandler<? super E>) receivedMessageHandlers.put(type, handler);
    }
1374017
function addHandlers(node, handlers, thisObject){
    node = getNode(node);

    for (var eventType in handlers)
      addHandler(node, eventType, handlers[eventType], thisObject);
  }
454606
def add_handler(self, handler):
        """"""
        if not callable(handler):
            raise TypeError("'%s' is not callable." % handler)

        self.append(handler)
791969
@Override
	public void addInputChannel(RemoteInputChannel listener) throws IOException {
		checkError();

		inputChannels.putIfAbsent(listener.getInputChannelId(), listener);
	}
12846
private void configureClearTextWithPriorKnowledge(SocketChannel ch) {
        ch.pipeline().addLast(connectionHandler,
            new PrefaceFrameWrittenEventHandler(),
            new UserEventLogger());
        configureEndOfPipeline(ch.pipeline());
    }
674431
private void configureSSL(SocketChannel ch) {
        final ChannelPipeline p = ch.pipeline();
        // 先通过 SSL/TLS 协商版本
        p.addLast(sslCtx.newHandler(ch.alloc()));
        // 根据版本加载不同的 ChannelHandler
        p.addLast(new ApplicationProtocolNegotiationHandler(ApplicationProtocolNames.HTTP_1_1) {
            @Override
            protected void configurePipeline(ChannelHandlerContext ctx, String protocol) throws Exception {
                if (ApplicationProtocolNames.HTTP_2.equals(protocol)) {
                    ctx.pipeline().addLast(bizGroup, "Http2ChannelHandler",
                        new Http2ChannelHandlerBuilder(serverHandler).build());
                    return;
                }

                if (ApplicationProtocolNames.HTTP_1_1.equals(protocol)) {
                    ctx.pipeline().addLast("HttpServerCodec", new HttpServerCodec());
                    ctx.pipeline().addLast("HttpObjectAggregator", new HttpObjectAggregator(maxHttpContentLength));
                    ctx.pipeline().addLast(bizGroup, "Http1ChannelHandler",
                        new Http1ServerChannelHandler(serverHandler));
                    return;
                }

                throw new IllegalStateException("unknown protocol: " + protocol);
            }
        });
    }
787487
@Override
  protected void initChannel(final Channel ch) throws Exception {
    ChannelPipeline pipeline = ch.pipeline();

    if (environment.sslEnabled()) {
      pipeline.addLast(new SslHandler(sslEngineFactory.get()));
    }
    if (LOGGER.isTraceEnabled()) {
      pipeline.addLast(new LoggingHandler(LogLevel.TRACE));
    }
    CredentialsProvider credentialsProvider = environment.credentialsProvider();
    Credentials credentials = credentialsProvider.get(address);
    pipeline
        .addLast(new HttpClientCodec())
        .addLast(new StartStreamHandler(bucket, credentials.getUsername(), credentials.getPassword()))
        .addLast(new ConfigHandler(configStream, currentBucketConfigRev, environment));
  }
146052
static void closeOnFlush(Channel ch) {
        if (ch.isActive()) {
            ch.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
        }
    }
46406
public SelectionKey register (SelectableChannel chan, int ops, NetEventHandler netEventHandler)
        throws IOException
    {
        SelectionKey key = chan.register(_selector, ops);
        _handlers.put(key, netEventHandler);
        return key;
    }
1003788
private void configureAsHttps(Channel ch, InetSocketAddress remoteAddr) {
        assert sslCtx != null;

        final ChannelPipeline p = ch.pipeline();
        final SslHandler sslHandler = sslCtx.newHandler(ch.alloc(),
                                                        remoteAddr.getHostString(),
                                                        remoteAddr.getPort());
        p.addLast(configureSslHandler(sslHandler));
        p.addLast(TrafficLoggingHandler.CLIENT);
        p.addLast(new ChannelInboundHandlerAdapter() {
            private boolean handshakeFailed;

            @Override
            public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
                if (!(evt instanceof SslHandshakeCompletionEvent)) {
                    ctx.fireUserEventTriggered(evt);
                    return;
                }

                final SslHandshakeCompletionEvent handshakeEvent = (SslHandshakeCompletionEvent) evt;
                if (!handshakeEvent.isSuccess()) {
                    // The connection will be closed automatically by SslHandler.
                    logger.warn("{} TLS handshake failed:", ctx.channel(), handshakeEvent.cause());
                    handshakeFailed = true;
                    return;
                }

                final SessionProtocol protocol;
                if (isHttp2Protocol(sslHandler)) {
                    if (httpPreference == HttpPreference.HTTP1_REQUIRED) {
                        finishWithNegotiationFailure(ctx, H1, H2, "unexpected protocol negotiation result");
                        return;
                    }

                    addBeforeSessionHandler(p, newHttp2ConnectionHandler(ch));
                    protocol = H2;
                } else {
                    if (httpPreference != HttpPreference.HTTP1_REQUIRED) {
                        SessionProtocolNegotiationCache.setUnsupported(ctx.channel().remoteAddress(), H2);
                    }

                    if (httpPreference == HttpPreference.HTTP2_REQUIRED) {
                        finishWithNegotiationFailure(ctx, H2, H1, "unexpected protocol negotiation result");
                        return;
                    }

                    addBeforeSessionHandler(p, newHttp1Codec(
                            clientFactory.http1MaxInitialLineLength(),
                            clientFactory.http1MaxHeaderSize(),
                            clientFactory.http1MaxChunkSize()));
                    protocol = H1;
                }
                finishSuccessfully(p, protocol);
                p.remove(this);
            }

            @Override
            public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
                if (handshakeFailed &&
                    cause instanceof DecoderException &&
                    cause.getCause() instanceof SSLException) {
                    // Swallow an SSLException raised after handshake failure.
                    return;
                }

                Exceptions.logIfUnexpected(logger, ctx.channel(), cause);
                ctx.close();
            }
        });
    }
461007
void modify(AbstractEpollChannel ch) throws IOException {
        assert inEventLoop();
        Native.epollCtlMod(epollFd.intValue(), ch.socket.intValue(), ch.flags);
    }