当前位置: 首页 > article >正文

netty之ServerBootstrap和Bootstrap

简介

其作为netty启动引导,配置eventloop以及handler等netty的基础组件

结构

«abstract»
AbstractBootstrap<B, C>
ServerBootstrap
Bootstrap
«interface»
ChannelFactory<T>
«abstract»
AbstractBootstrapConfig<B, C>
ServerBootstrapConfig
BootstrapConfig

ServerBootstrap

«abstract»
ChannelInitializer<C>
#void initChannel(C ch)
ChannelInboundHandlerAdapter
ServerBootstrapAcceptor
ServerBootstrap

ChannelInitializer:用于在注册完成时添加新连接时的ChannelHandler,其保证只执行一次,不会重复添加

private boolean initChannel(ChannelHandlerContext ctx) throws Exception {
        if (initMap.add(ctx)) { // Guard against re-entrance.
            try {
                initChannel((C) ctx.channel());
            } catch (Throwable cause) {
                // Explicitly call exceptionCaught(...) as we removed the handler before calling initChannel(...).
                // We do so to prevent multiple calls to initChannel(...).
                exceptionCaught(ctx, cause);
            } finally {
                ChannelPipeline pipeline = ctx.pipeline();
                if (pipeline.context(this) != null) {
                    pipeline.remove(this);
                }
            }
            return true;
        }
        return false;
    }

http://www.kler.cn/news/368520.html

相关文章:

  • STM32 第17章 EXIT--外部中断/事件控制器
  • 保研考研机试攻略:python笔记(1)
  • JDBC: Java数据库连接的桥梁
  • Python中的递归函数是如何工作的,它有哪些应用场景?
  • <<机器学习实战>>15-26节笔记:逻辑回归参数估计、梯度下降及优化、模型评价指标
  • Rust教程
  • 优先算法:双指针、移动零
  • 程序员修仙传
  • Git详解
  • 使用教程:基于 uiautomator2 和 pytest 的图片相似度测试脚本
  • BERT 的 12 层维度变化详解:从输入到输出的逐步剖析
  • Kafka消费者故障,出现活锁问题如何解决?
  • UE材质节点arctangent2解析
  • 重学SpringBoot3-Spring WebFlux之Reactor事件感知 API
  • 机器视觉:9点标定的原理与实现
  • [专有网络VPC]ECS安全组配置案例
  • 【Python知识】一个强大的数据分析库Pandas
  • 基于Python的B站视频数据分析与可视化
  • Spring Boot框架下租房管理系统的设计与实现
  • spring-ai-alibaba下载
  • 【认知智能】编译器1
  • DataX
  • Oracle 权限相关的概念
  • Chromium HTML5 新的 Input 类型email对应c++
  • pikachu靶场-Cross-Site Scripting(XSS)
  • node学习笔记