Dubbo SPI 机制:ExtensionLoader 原理深度解析

Dubbo SPI 机制:ExtensionLoader 原理深度解析

前言

Apache Dubbo 作为一款高性能的 Java RPC 框架,其强大的可扩展性一直是开发者津津乐道的话题。而在 Dubbo 的众多设计亮点中,SPI (Service Provider Interface) 机制无疑是最为核心的内容之一。本文将从源码角度深入剖析 Dubbo SPI 的核心实现类 ExtensionLoader,带您领略这一优秀框架设计的精髓。

阅读本文,您将学到: - Dubbo SPI 与 Java SPI 的本质区别 - ExtensionLoader 的核心工作原理 - IOC 和 AOP 在 Dubbo SPI 中的实现 - 自适应扩展机制的奥秘 - 如何在实际项目中优雅使用 Dubbo SPI


一、SPI 机制概述

1.1 什么是 SPI

SPI (Service Provider Interface) 是一种服务发现机制,它允许第三方提供者为核心框架提供实现或扩展。简单来说,SPI 让框架可以在运行时动态加载实现类,而不需要修改框架源代码。

1.2 Java SPI vs Dubbo SPI

Java 提供了标准的 SPI 机制,但 Dubbo 在此基础上进行了增强。让我们通过对比表格来了解两者的差异:

表 1-1: Java SPI 与 Dubbo SPI 核心特性对比
特性 Java SPI Dubbo SPI
配置文件位置 META-INF/services/ META-INF/dubbo/META-INF/services/META-INF/dubbo/internal/
实例化方式 全部实例化 按需实例化(懒加载)
IOC 支持 ❌ 不支持 ✅ 支持依赖注入
AOP 支持 ❌ 不支持 ✅ 支持包装类(Wrapper)
扩展点配置 单一实现 支持别名、默认值、激活条件
扩展点自适应 ❌ 不支持 ✅ 支持自适应扩展($Adaptive)
扩展点依赖 ❌ 无依赖管理 ✅ 支持扩展点之间的依赖
异常处理 遍历所有实现,遇到异常才终止 优雅处理,提供详细的异常信息
表 1-2: SPI 配置文件格式对比

Java SPI 格式:

复制代码
com.example.impl.MyServiceImpl
com.example.impl.AnotherServiceImpl

Dubbo SPI 格式:

复制代码
myImpl=com.example.impl.MyServiceImpl
anotherImpl=com.example.impl.AnotherServiceImpl
default=com.example.impl.DefaultServiceImpl

关键区别: - Dubbo SPI 支持为实现类指定别名(如 myImpl),便于在配置中引用 - 支持设置默认实现(@SPI("default")) - 支持条件激活(@Activate)


二、Dubbo SPI 核心概念

2.1 扩展点(Extension Point)

扩展点是一个接口,定义了可以被扩展的功能。在 Dubbo 中,扩展点接口需要使用 @SPI 注解标注。

示例:

java 复制代码
#@SPI("default") // 指定默认扩展名为 "default"
public interface Robot {
    void sayHello();
}@SPI("default") // 指定默认扩展名为 "default"`
`#@SPI("default") // 指定默认扩展名为 "default"
public interface Robot {
    void sayHello();
}public interface Robot {`
`#@SPI("default") // 指定默认扩展名为 "default"
public interface Robot {
    void sayHello();
}    void sayHello();`
`#@SPI("default") // 指定默认扩展名为 "default"
public interface Robot {
    void sayHello();
}}

2.2 扩展实现(Extension)

扩展实现是扩展点接口的具体实现类。每个实现类都需要在配置文件中注册。

配置文件路径: META-INF/dubbo/com.example.Robot

配置内容:

复制代码
optimusPrime=com.example.impl.OptimusPrime
bumblebee=com.example.impl.Bumblebee
default=com.example.impl.DefaultRobot

2.3 扩展加载器(ExtensionLoader)

ExtensionLoader 是 Dubbo SPI 的核心类,负责: 1. 加载扩展点配置 2. 缓存扩展实例 3. 实现 IOC 依赖注入 4. 实现 AOP 包装类处理 5. 创建自适应扩展


三、ExtensionLoader 核心原理

3.1 ExtensionLoader 类结构

首先,让我们了解 ExtensionLoader 的核心成员变量:

源码版本: Dubbo 3.2.9

java 复制代码
#public class ExtensionLoader<T> {
    // 扩展点接口的 Class 对象
    private final Class<?> type;
    
    // 扩展点注入器(用于 IOC)
    private final ExtensionFactory objectFactory;
    
    // 扩展点实例缓存 (扩展名 -> 扩展实例)
    private final ConcurrentMap<String, Holder<Object>> cachedInstances = new ConcurrentHashMap<>();
    
    // 扩展点 Class 缓存 (扩展名 -> 扩展 Class)
    private final ConcurrentHashMap<String, Class<?>> cachedClasses = new ConcurrentHashMap<>();
    
    // 自适应扩展实例缓存
    private final Holder<Object> cachedAdaptiveInstance = new Holder<>();
    
    // 默认扩展名
    private String cachedDefaultName;
    
    // 缓存扩展点的 @Activate 注解信息
    private final Map<String, Object> cachedActivates = new ConcurrentHashMap<>();
    
    // 扩展点包装类缓存
    private Set<Class<?>> cachedWrapperClasses;
    
    // 扩展点名称到 Class 的映射
    private Map<String, Class<?>> extensionClasses; // volatile
    
    // 扩展点加载状态标志
    private volatile boolean extensionClassesInitied = false;
}public class ExtensionLoader<T> {`
`#public class ExtensionLoader<T> {
    // 扩展点接口的 Class 对象
    private final Class<?> type;
    
    // 扩展点注入器(用于 IOC)
    private final ExtensionFactory objectFactory;
    
    // 扩展点实例缓存 (扩展名 -> 扩展实例)
    private final ConcurrentMap<String, Holder<Object>> cachedInstances = new ConcurrentHashMap<>();
    
    // 扩展点 Class 缓存 (扩展名 -> 扩展 Class)
    private final ConcurrentHashMap<String, Class<?>> cachedClasses = new ConcurrentHashMap<>();
    
    // 自适应扩展实例缓存
    private final Holder<Object> cachedAdaptiveInstance = new Holder<>();
    
    // 默认扩展名
    private String cachedDefaultName;
    
    // 缓存扩展点的 @Activate 注解信息
    private final Map<String, Object> cachedActivates = new ConcurrentHashMap<>();
    
    // 扩展点包装类缓存
    private Set<Class<?>> cachedWrapperClasses;
    
    // 扩展点名称到 Class 的映射
    private Map<String, Class<?>> extensionClasses; // volatile
    
    // 扩展点加载状态标志
    private volatile boolean extensionClassesInitied = false;
}    // 扩展点接口的 Class 对象`
`#public class ExtensionLoader<T> {
    // 扩展点接口的 Class 对象
    private final Class<?> type;
    
    // 扩展点注入器(用于 IOC)
    private final ExtensionFactory objectFactory;
    
    // 扩展点实例缓存 (扩展名 -> 扩展实例)
    private final ConcurrentMap<String, Holder<Object>> cachedInstances = new ConcurrentHashMap<>();
    
    // 扩展点 Class 缓存 (扩展名 -> 扩展 Class)
    private final ConcurrentHashMap<String, Class<?>> cachedClasses = new ConcurrentHashMap<>();
    
    // 自适应扩展实例缓存
    private final Holder<Object> cachedAdaptiveInstance = new Holder<>();
    
    // 默认扩展名
    private String cachedDefaultName;
    
    // 缓存扩展点的 @Activate 注解信息
    private final Map<String, Object> cachedActivates = new ConcurrentHashMap<>();
    
    // 扩展点包装类缓存
    private Set<Class<?>> cachedWrapperClasses;
    
    // 扩展点名称到 Class 的映射
    private Map<String, Class<?>> extensionClasses; // volatile
    
    // 扩展点加载状态标志
    private volatile boolean extensionClassesInitied = false;
}    private final Class<?> type;`
`#public class ExtensionLoader<T> {
    // 扩展点接口的 Class 对象
    private final Class<?> type;
    
    // 扩展点注入器(用于 IOC)
    private final ExtensionFactory objectFactory;
    
    // 扩展点实例缓存 (扩展名 -> 扩展实例)
    private final ConcurrentMap<String, Holder<Object>> cachedInstances = new ConcurrentHashMap<>();
    
    // 扩展点 Class 缓存 (扩展名 -> 扩展 Class)
    private final ConcurrentHashMap<String, Class<?>> cachedClasses = new ConcurrentHashMap<>();
    
    // 自适应扩展实例缓存
    private final Holder<Object> cachedAdaptiveInstance = new Holder<>();
    
    // 默认扩展名
    private String cachedDefaultName;
    
    // 缓存扩展点的 @Activate 注解信息
    private final Map<String, Object> cachedActivates = new ConcurrentHashMap<>();
    
    // 扩展点包装类缓存
    private Set<Class<?>> cachedWrapperClasses;
    
    // 扩展点名称到 Class 的映射
    private Map<String, Class<?>> extensionClasses; // volatile
    
    // 扩展点加载状态标志
    private volatile boolean extensionClassesInitied = false;
}    `
`#public class ExtensionLoader<T> {
    // 扩展点接口的 Class 对象
    private final Class<?> type;
    
    // 扩展点注入器(用于 IOC)
    private final ExtensionFactory objectFactory;
    
    // 扩展点实例缓存 (扩展名 -> 扩展实例)
    private final ConcurrentMap<String, Holder<Object>> cachedInstances = new ConcurrentHashMap<>();
    
    // 扩展点 Class 缓存 (扩展名 -> 扩展 Class)
    private final ConcurrentHashMap<String, Class<?>> cachedClasses = new ConcurrentHashMap<>();
    
    // 自适应扩展实例缓存
    private final Holder<Object> cachedAdaptiveInstance = new Holder<>();
    
    // 默认扩展名
    private String cachedDefaultName;
    
    // 缓存扩展点的 @Activate 注解信息
    private final Map<String, Object> cachedActivates = new ConcurrentHashMap<>();
    
    // 扩展点包装类缓存
    private Set<Class<?>> cachedWrapperClasses;
    
    // 扩展点名称到 Class 的映射
    private Map<String, Class<?>> extensionClasses; // volatile
    
    // 扩展点加载状态标志
    private volatile boolean extensionClassesInitied = false;
}    // 扩展点注入器(用于 IOC)`
`#public class ExtensionLoader<T> {
    // 扩展点接口的 Class 对象
    private final Class<?> type;
    
    // 扩展点注入器(用于 IOC)
    private final ExtensionFactory objectFactory;
    
    // 扩展点实例缓存 (扩展名 -> 扩展实例)
    private final ConcurrentMap<String, Holder<Object>> cachedInstances = new ConcurrentHashMap<>();
    
    // 扩展点 Class 缓存 (扩展名 -> 扩展 Class)
    private final ConcurrentHashMap<String, Class<?>> cachedClasses = new ConcurrentHashMap<>();
    
    // 自适应扩展实例缓存
    private final Holder<Object> cachedAdaptiveInstance = new Holder<>();
    
    // 默认扩展名
    private String cachedDefaultName;
    
    // 缓存扩展点的 @Activate 注解信息
    private final Map<String, Object> cachedActivates = new ConcurrentHashMap<>();
    
    // 扩展点包装类缓存
    private Set<Class<?>> cachedWrapperClasses;
    
    // 扩展点名称到 Class 的映射
    private Map<String, Class<?>> extensionClasses; // volatile
    
    // 扩展点加载状态标志
    private volatile boolean extensionClassesInitied = false;
}    private final ExtensionFactory objectFactory;`
`#public class ExtensionLoader<T> {
    // 扩展点接口的 Class 对象
    private final Class<?> type;
    
    // 扩展点注入器(用于 IOC)
    private final ExtensionFactory objectFactory;
    
    // 扩展点实例缓存 (扩展名 -> 扩展实例)
    private final ConcurrentMap<String, Holder<Object>> cachedInstances = new ConcurrentHashMap<>();
    
    // 扩展点 Class 缓存 (扩展名 -> 扩展 Class)
    private final ConcurrentHashMap<String, Class<?>> cachedClasses = new ConcurrentHashMap<>();
    
    // 自适应扩展实例缓存
    private final Holder<Object> cachedAdaptiveInstance = new Holder<>();
    
    // 默认扩展名
    private String cachedDefaultName;
    
    // 缓存扩展点的 @Activate 注解信息
    private final Map<String, Object> cachedActivates = new ConcurrentHashMap<>();
    
    // 扩展点包装类缓存
    private Set<Class<?>> cachedWrapperClasses;
    
    // 扩展点名称到 Class 的映射
    private Map<String, Class<?>> extensionClasses; // volatile
    
    // 扩展点加载状态标志
    private volatile boolean extensionClassesInitied = false;
}    `
`#public class ExtensionLoader<T> {
    // 扩展点接口的 Class 对象
    private final Class<?> type;
    
    // 扩展点注入器(用于 IOC)
    private final ExtensionFactory objectFactory;
    
    // 扩展点实例缓存 (扩展名 -> 扩展实例)
    private final ConcurrentMap<String, Holder<Object>> cachedInstances = new ConcurrentHashMap<>();
    
    // 扩展点 Class 缓存 (扩展名 -> 扩展 Class)
    private final ConcurrentHashMap<String, Class<?>> cachedClasses = new ConcurrentHashMap<>();
    
    // 自适应扩展实例缓存
    private final Holder<Object> cachedAdaptiveInstance = new Holder<>();
    
    // 默认扩展名
    private String cachedDefaultName;
    
    // 缓存扩展点的 @Activate 注解信息
    private final Map<String, Object> cachedActivates = new ConcurrentHashMap<>();
    
    // 扩展点包装类缓存
    private Set<Class<?>> cachedWrapperClasses;
    
    // 扩展点名称到 Class 的映射
    private Map<String, Class<?>> extensionClasses; // volatile
    
    // 扩展点加载状态标志
    private volatile boolean extensionClassesInitied = false;
}    // 扩展点实例缓存 (扩展名 -> 扩展实例)`
`#public class ExtensionLoader<T> {
    // 扩展点接口的 Class 对象
    private final Class<?> type;
    
    // 扩展点注入器(用于 IOC)
    private final ExtensionFactory objectFactory;
    
    // 扩展点实例缓存 (扩展名 -> 扩展实例)
    private final ConcurrentMap<String, Holder<Object>> cachedInstances = new ConcurrentHashMap<>();
    
    // 扩展点 Class 缓存 (扩展名 -> 扩展 Class)
    private final ConcurrentHashMap<String, Class<?>> cachedClasses = new ConcurrentHashMap<>();
    
    // 自适应扩展实例缓存
    private final Holder<Object> cachedAdaptiveInstance = new Holder<>();
    
    // 默认扩展名
    private String cachedDefaultName;
    
    // 缓存扩展点的 @Activate 注解信息
    private final Map<String, Object> cachedActivates = new ConcurrentHashMap<>();
    
    // 扩展点包装类缓存
    private Set<Class<?>> cachedWrapperClasses;
    
    // 扩展点名称到 Class 的映射
    private Map<String, Class<?>> extensionClasses; // volatile
    
    // 扩展点加载状态标志
    private volatile boolean extensionClassesInitied = false;
}    private final ConcurrentMap<String, Holder<Object>> cachedInstances = new ConcurrentHashMap<>();`
`#public class ExtensionLoader<T> {
    // 扩展点接口的 Class 对象
    private final Class<?> type;
    
    // 扩展点注入器(用于 IOC)
    private final ExtensionFactory objectFactory;
    
    // 扩展点实例缓存 (扩展名 -> 扩展实例)
    private final ConcurrentMap<String, Holder<Object>> cachedInstances = new ConcurrentHashMap<>();
    
    // 扩展点 Class 缓存 (扩展名 -> 扩展 Class)
    private final ConcurrentHashMap<String, Class<?>> cachedClasses = new ConcurrentHashMap<>();
    
    // 自适应扩展实例缓存
    private final Holder<Object> cachedAdaptiveInstance = new Holder<>();
    
    // 默认扩展名
    private String cachedDefaultName;
    
    // 缓存扩展点的 @Activate 注解信息
    private final Map<String, Object> cachedActivates = new ConcurrentHashMap<>();
    
    // 扩展点包装类缓存
    private Set<Class<?>> cachedWrapperClasses;
    
    // 扩展点名称到 Class 的映射
    private Map<String, Class<?>> extensionClasses; // volatile
    
    // 扩展点加载状态标志
    private volatile boolean extensionClassesInitied = false;
}    `
`#public class ExtensionLoader<T> {
    // 扩展点接口的 Class 对象
    private final Class<?> type;
    
    // 扩展点注入器(用于 IOC)
    private final ExtensionFactory objectFactory;
    
    // 扩展点实例缓存 (扩展名 -> 扩展实例)
    private final ConcurrentMap<String, Holder<Object>> cachedInstances = new ConcurrentHashMap<>();
    
    // 扩展点 Class 缓存 (扩展名 -> 扩展 Class)
    private final ConcurrentHashMap<String, Class<?>> cachedClasses = new ConcurrentHashMap<>();
    
    // 自适应扩展实例缓存
    private final Holder<Object> cachedAdaptiveInstance = new Holder<>();
    
    // 默认扩展名
    private String cachedDefaultName;
    
    // 缓存扩展点的 @Activate 注解信息
    private final Map<String, Object> cachedActivates = new ConcurrentHashMap<>();
    
    // 扩展点包装类缓存
    private Set<Class<?>> cachedWrapperClasses;
    
    // 扩展点名称到 Class 的映射
    private Map<String, Class<?>> extensionClasses; // volatile
    
    // 扩展点加载状态标志
    private volatile boolean extensionClassesInitied = false;
}    // 扩展点 Class 缓存 (扩展名 -> 扩展 Class)`
`#public class ExtensionLoader<T> {
    // 扩展点接口的 Class 对象
    private final Class<?> type;
    
    // 扩展点注入器(用于 IOC)
    private final ExtensionFactory objectFactory;
    
    // 扩展点实例缓存 (扩展名 -> 扩展实例)
    private final ConcurrentMap<String, Holder<Object>> cachedInstances = new ConcurrentHashMap<>();
    
    // 扩展点 Class 缓存 (扩展名 -> 扩展 Class)
    private final ConcurrentHashMap<String, Class<?>> cachedClasses = new ConcurrentHashMap<>();
    
    // 自适应扩展实例缓存
    private final Holder<Object> cachedAdaptiveInstance = new Holder<>();
    
    // 默认扩展名
    private String cachedDefaultName;
    
    // 缓存扩展点的 @Activate 注解信息
    private final Map<String, Object> cachedActivates = new ConcurrentHashMap<>();
    
    // 扩展点包装类缓存
    private Set<Class<?>> cachedWrapperClasses;
    
    // 扩展点名称到 Class 的映射
    private Map<String, Class<?>> extensionClasses; // volatile
    
    // 扩展点加载状态标志
    private volatile boolean extensionClassesInitied = false;
}    private final ConcurrentHashMap<String, Class<?>> cachedClasses = new ConcurrentHashMap<>();`
`#public class ExtensionLoader<T> {
    // 扩展点接口的 Class 对象
    private final Class<?> type;
    
    // 扩展点注入器(用于 IOC)
    private final ExtensionFactory objectFactory;
    
    // 扩展点实例缓存 (扩展名 -> 扩展实例)
    private final ConcurrentMap<String, Holder<Object>> cachedInstances = new ConcurrentHashMap<>();
    
    // 扩展点 Class 缓存 (扩展名 -> 扩展 Class)
    private final ConcurrentHashMap<String, Class<?>> cachedClasses = new ConcurrentHashMap<>();
    
    // 自适应扩展实例缓存
    private final Holder<Object> cachedAdaptiveInstance = new Holder<>();
    
    // 默认扩展名
    private String cachedDefaultName;
    
    // 缓存扩展点的 @Activate 注解信息
    private final Map<String, Object> cachedActivates = new ConcurrentHashMap<>();
    
    // 扩展点包装类缓存
    private Set<Class<?>> cachedWrapperClasses;
    
    // 扩展点名称到 Class 的映射
    private Map<String, Class<?>> extensionClasses; // volatile
    
    // 扩展点加载状态标志
    private volatile boolean extensionClassesInitied = false;
}    `
`#public class ExtensionLoader<T> {
    // 扩展点接口的 Class 对象
    private final Class<?> type;
    
    // 扩展点注入器(用于 IOC)
    private final ExtensionFactory objectFactory;
    
    // 扩展点实例缓存 (扩展名 -> 扩展实例)
    private final ConcurrentMap<String, Holder<Object>> cachedInstances = new ConcurrentHashMap<>();
    
    // 扩展点 Class 缓存 (扩展名 -> 扩展 Class)
    private final ConcurrentHashMap<String, Class<?>> cachedClasses = new ConcurrentHashMap<>();
    
    // 自适应扩展实例缓存
    private final Holder<Object> cachedAdaptiveInstance = new Holder<>();
    
    // 默认扩展名
    private String cachedDefaultName;
    
    // 缓存扩展点的 @Activate 注解信息
    private final Map<String, Object> cachedActivates = new ConcurrentHashMap<>();
    
    // 扩展点包装类缓存
    private Set<Class<?>> cachedWrapperClasses;
    
    // 扩展点名称到 Class 的映射
    private Map<String, Class<?>> extensionClasses; // volatile
    
    // 扩展点加载状态标志
    private volatile boolean extensionClassesInitied = false;
}    // 自适应扩展实例缓存`
`#public class ExtensionLoader<T> {
    // 扩展点接口的 Class 对象
    private final Class<?> type;
    
    // 扩展点注入器(用于 IOC)
    private final ExtensionFactory objectFactory;
    
    // 扩展点实例缓存 (扩展名 -> 扩展实例)
    private final ConcurrentMap<String, Holder<Object>> cachedInstances = new ConcurrentHashMap<>();
    
    // 扩展点 Class 缓存 (扩展名 -> 扩展 Class)
    private final ConcurrentHashMap<String, Class<?>> cachedClasses = new ConcurrentHashMap<>();
    
    // 自适应扩展实例缓存
    private final Holder<Object> cachedAdaptiveInstance = new Holder<>();
    
    // 默认扩展名
    private String cachedDefaultName;
    
    // 缓存扩展点的 @Activate 注解信息
    private final Map<String, Object> cachedActivates = new ConcurrentHashMap<>();
    
    // 扩展点包装类缓存
    private Set<Class<?>> cachedWrapperClasses;
    
    // 扩展点名称到 Class 的映射
    private Map<String, Class<?>> extensionClasses; // volatile
    
    // 扩展点加载状态标志
    private volatile boolean extensionClassesInitied = false;
}    private final Holder<Object> cachedAdaptiveInstance = new Holder<>();`
`#public class ExtensionLoader<T> {
    // 扩展点接口的 Class 对象
    private final Class<?> type;
    
    // 扩展点注入器(用于 IOC)
    private final ExtensionFactory objectFactory;
    
    // 扩展点实例缓存 (扩展名 -> 扩展实例)
    private final ConcurrentMap<String, Holder<Object>> cachedInstances = new ConcurrentHashMap<>();
    
    // 扩展点 Class 缓存 (扩展名 -> 扩展 Class)
    private final ConcurrentHashMap<String, Class<?>> cachedClasses = new ConcurrentHashMap<>();
    
    // 自适应扩展实例缓存
    private final Holder<Object> cachedAdaptiveInstance = new Holder<>();
    
    // 默认扩展名
    private String cachedDefaultName;
    
    // 缓存扩展点的 @Activate 注解信息
    private final Map<String, Object> cachedActivates = new ConcurrentHashMap<>();
    
    // 扩展点包装类缓存
    private Set<Class<?>> cachedWrapperClasses;
    
    // 扩展点名称到 Class 的映射
    private Map<String, Class<?>> extensionClasses; // volatile
    
    // 扩展点加载状态标志
    private volatile boolean extensionClassesInitied = false;
}    `
`#public class ExtensionLoader<T> {
    // 扩展点接口的 Class 对象
    private final Class<?> type;
    
    // 扩展点注入器(用于 IOC)
    private final ExtensionFactory objectFactory;
    
    // 扩展点实例缓存 (扩展名 -> 扩展实例)
    private final ConcurrentMap<String, Holder<Object>> cachedInstances = new ConcurrentHashMap<>();
    
    // 扩展点 Class 缓存 (扩展名 -> 扩展 Class)
    private final ConcurrentHashMap<String, Class<?>> cachedClasses = new ConcurrentHashMap<>();
    
    // 自适应扩展实例缓存
    private final Holder<Object> cachedAdaptiveInstance = new Holder<>();
    
    // 默认扩展名
    private String cachedDefaultName;
    
    // 缓存扩展点的 @Activate 注解信息
    private final Map<String, Object> cachedActivates = new ConcurrentHashMap<>();
    
    // 扩展点包装类缓存
    private Set<Class<?>> cachedWrapperClasses;
    
    // 扩展点名称到 Class 的映射
    private Map<String, Class<?>> extensionClasses; // volatile
    
    // 扩展点加载状态标志
    private volatile boolean extensionClassesInitied = false;
}    // 默认扩展名`
`#public class ExtensionLoader<T> {
    // 扩展点接口的 Class 对象
    private final Class<?> type;
    
    // 扩展点注入器(用于 IOC)
    private final ExtensionFactory objectFactory;
    
    // 扩展点实例缓存 (扩展名 -> 扩展实例)
    private final ConcurrentMap<String, Holder<Object>> cachedInstances = new ConcurrentHashMap<>();
    
    // 扩展点 Class 缓存 (扩展名 -> 扩展 Class)
    private final ConcurrentHashMap<String, Class<?>> cachedClasses = new ConcurrentHashMap<>();
    
    // 自适应扩展实例缓存
    private final Holder<Object> cachedAdaptiveInstance = new Holder<>();
    
    // 默认扩展名
    private String cachedDefaultName;
    
    // 缓存扩展点的 @Activate 注解信息
    private final Map<String, Object> cachedActivates = new ConcurrentHashMap<>();
    
    // 扩展点包装类缓存
    private Set<Class<?>> cachedWrapperClasses;
    
    // 扩展点名称到 Class 的映射
    private Map<String, Class<?>> extensionClasses; // volatile
    
    // 扩展点加载状态标志
    private volatile boolean extensionClassesInitied = false;
}    private String cachedDefaultName;`
`#public class ExtensionLoader<T> {
    // 扩展点接口的 Class 对象
    private final Class<?> type;
    
    // 扩展点注入器(用于 IOC)
    private final ExtensionFactory objectFactory;
    
    // 扩展点实例缓存 (扩展名 -> 扩展实例)
    private final ConcurrentMap<String, Holder<Object>> cachedInstances = new ConcurrentHashMap<>();
    
    // 扩展点 Class 缓存 (扩展名 -> 扩展 Class)
    private final ConcurrentHashMap<String, Class<?>> cachedClasses = new ConcurrentHashMap<>();
    
    // 自适应扩展实例缓存
    private final Holder<Object> cachedAdaptiveInstance = new Holder<>();
    
    // 默认扩展名
    private String cachedDefaultName;
    
    // 缓存扩展点的 @Activate 注解信息
    private final Map<String, Object> cachedActivates = new ConcurrentHashMap<>();
    
    // 扩展点包装类缓存
    private Set<Class<?>> cachedWrapperClasses;
    
    // 扩展点名称到 Class 的映射
    private Map<String, Class<?>> extensionClasses; // volatile
    
    // 扩展点加载状态标志
    private volatile boolean extensionClassesInitied = false;
}    `
`#public class ExtensionLoader<T> {
    // 扩展点接口的 Class 对象
    private final Class<?> type;
    
    // 扩展点注入器(用于 IOC)
    private final ExtensionFactory objectFactory;
    
    // 扩展点实例缓存 (扩展名 -> 扩展实例)
    private final ConcurrentMap<String, Holder<Object>> cachedInstances = new ConcurrentHashMap<>();
    
    // 扩展点 Class 缓存 (扩展名 -> 扩展 Class)
    private final ConcurrentHashMap<String, Class<?>> cachedClasses = new ConcurrentHashMap<>();
    
    // 自适应扩展实例缓存
    private final Holder<Object> cachedAdaptiveInstance = new Holder<>();
    
    // 默认扩展名
    private String cachedDefaultName;
    
    // 缓存扩展点的 @Activate 注解信息
    private final Map<String, Object> cachedActivates = new ConcurrentHashMap<>();
    
    // 扩展点包装类缓存
    private Set<Class<?>> cachedWrapperClasses;
    
    // 扩展点名称到 Class 的映射
    private Map<String, Class<?>> extensionClasses; // volatile
    
    // 扩展点加载状态标志
    private volatile boolean extensionClassesInitied = false;
}    // 缓存扩展点的 @Activate 注解信息`
`#public class ExtensionLoader<T> {
    // 扩展点接口的 Class 对象
    private final Class<?> type;
    
    // 扩展点注入器(用于 IOC)
    private final ExtensionFactory objectFactory;
    
    // 扩展点实例缓存 (扩展名 -> 扩展实例)
    private final ConcurrentMap<String, Holder<Object>> cachedInstances = new ConcurrentHashMap<>();
    
    // 扩展点 Class 缓存 (扩展名 -> 扩展 Class)
    private final ConcurrentHashMap<String, Class<?>> cachedClasses = new ConcurrentHashMap<>();
    
    // 自适应扩展实例缓存
    private final Holder<Object> cachedAdaptiveInstance = new Holder<>();
    
    // 默认扩展名
    private String cachedDefaultName;
    
    // 缓存扩展点的 @Activate 注解信息
    private final Map<String, Object> cachedActivates = new ConcurrentHashMap<>();
    
    // 扩展点包装类缓存
    private Set<Class<?>> cachedWrapperClasses;
    
    // 扩展点名称到 Class 的映射
    private Map<String, Class<?>> extensionClasses; // volatile
    
    // 扩展点加载状态标志
    private volatile boolean extensionClassesInitied = false;
}    private final Map<String, Object> cachedActivates = new ConcurrentHashMap<>();`
`#public class ExtensionLoader<T> {
    // 扩展点接口的 Class 对象
    private final Class<?> type;
    
    // 扩展点注入器(用于 IOC)
    private final ExtensionFactory objectFactory;
    
    // 扩展点实例缓存 (扩展名 -> 扩展实例)
    private final ConcurrentMap<String, Holder<Object>> cachedInstances = new ConcurrentHashMap<>();
    
    // 扩展点 Class 缓存 (扩展名 -> 扩展 Class)
    private final ConcurrentHashMap<String, Class<?>> cachedClasses = new ConcurrentHashMap<>();
    
    // 自适应扩展实例缓存
    private final Holder<Object> cachedAdaptiveInstance = new Holder<>();
    
    // 默认扩展名
    private String cachedDefaultName;
    
    // 缓存扩展点的 @Activate 注解信息
    private final Map<String, Object> cachedActivates = new ConcurrentHashMap<>();
    
    // 扩展点包装类缓存
    private Set<Class<?>> cachedWrapperClasses;
    
    // 扩展点名称到 Class 的映射
    private Map<String, Class<?>> extensionClasses; // volatile
    
    // 扩展点加载状态标志
    private volatile boolean extensionClassesInitied = false;
}    `
`#public class ExtensionLoader<T> {
    // 扩展点接口的 Class 对象
    private final Class<?> type;
    
    // 扩展点注入器(用于 IOC)
    private final ExtensionFactory objectFactory;
    
    // 扩展点实例缓存 (扩展名 -> 扩展实例)
    private final ConcurrentMap<String, Holder<Object>> cachedInstances = new ConcurrentHashMap<>();
    
    // 扩展点 Class 缓存 (扩展名 -> 扩展 Class)
    private final ConcurrentHashMap<String, Class<?>> cachedClasses = new ConcurrentHashMap<>();
    
    // 自适应扩展实例缓存
    private final Holder<Object> cachedAdaptiveInstance = new Holder<>();
    
    // 默认扩展名
    private String cachedDefaultName;
    
    // 缓存扩展点的 @Activate 注解信息
    private final Map<String, Object> cachedActivates = new ConcurrentHashMap<>();
    
    // 扩展点包装类缓存
    private Set<Class<?>> cachedWrapperClasses;
    
    // 扩展点名称到 Class 的映射
    private Map<String, Class<?>> extensionClasses; // volatile
    
    // 扩展点加载状态标志
    private volatile boolean extensionClassesInitied = false;
}    // 扩展点包装类缓存`
`#public class ExtensionLoader<T> {
    // 扩展点接口的 Class 对象
    private final Class<?> type;
    
    // 扩展点注入器(用于 IOC)
    private final ExtensionFactory objectFactory;
    
    // 扩展点实例缓存 (扩展名 -> 扩展实例)
    private final ConcurrentMap<String, Holder<Object>> cachedInstances = new ConcurrentHashMap<>();
    
    // 扩展点 Class 缓存 (扩展名 -> 扩展 Class)
    private final ConcurrentHashMap<String, Class<?>> cachedClasses = new ConcurrentHashMap<>();
    
    // 自适应扩展实例缓存
    private final Holder<Object> cachedAdaptiveInstance = new Holder<>();
    
    // 默认扩展名
    private String cachedDefaultName;
    
    // 缓存扩展点的 @Activate 注解信息
    private final Map<String, Object> cachedActivates = new ConcurrentHashMap<>();
    
    // 扩展点包装类缓存
    private Set<Class<?>> cachedWrapperClasses;
    
    // 扩展点名称到 Class 的映射
    private Map<String, Class<?>> extensionClasses; // volatile
    
    // 扩展点加载状态标志
    private volatile boolean extensionClassesInitied = false;
}    private Set<Class<?>> cachedWrapperClasses;`
`#public class ExtensionLoader<T> {
    // 扩展点接口的 Class 对象
    private final Class<?> type;
    
    // 扩展点注入器(用于 IOC)
    private final ExtensionFactory objectFactory;
    
    // 扩展点实例缓存 (扩展名 -> 扩展实例)
    private final ConcurrentMap<String, Holder<Object>> cachedInstances = new ConcurrentHashMap<>();
    
    // 扩展点 Class 缓存 (扩展名 -> 扩展 Class)
    private final ConcurrentHashMap<String, Class<?>> cachedClasses = new ConcurrentHashMap<>();
    
    // 自适应扩展实例缓存
    private final Holder<Object> cachedAdaptiveInstance = new Holder<>();
    
    // 默认扩展名
    private String cachedDefaultName;
    
    // 缓存扩展点的 @Activate 注解信息
    private final Map<String, Object> cachedActivates = new ConcurrentHashMap<>();
    
    // 扩展点包装类缓存
    private Set<Class<?>> cachedWrapperClasses;
    
    // 扩展点名称到 Class 的映射
    private Map<String, Class<?>> extensionClasses; // volatile
    
    // 扩展点加载状态标志
    private volatile boolean extensionClassesInitied = false;
}    `
`#public class ExtensionLoader<T> {
    // 扩展点接口的 Class 对象
    private final Class<?> type;
    
    // 扩展点注入器(用于 IOC)
    private final ExtensionFactory objectFactory;
    
    // 扩展点实例缓存 (扩展名 -> 扩展实例)
    private final ConcurrentMap<String, Holder<Object>> cachedInstances = new ConcurrentHashMap<>();
    
    // 扩展点 Class 缓存 (扩展名 -> 扩展 Class)
    private final ConcurrentHashMap<String, Class<?>> cachedClasses = new ConcurrentHashMap<>();
    
    // 自适应扩展实例缓存
    private final Holder<Object> cachedAdaptiveInstance = new Holder<>();
    
    // 默认扩展名
    private String cachedDefaultName;
    
    // 缓存扩展点的 @Activate 注解信息
    private final Map<String, Object> cachedActivates = new ConcurrentHashMap<>();
    
    // 扩展点包装类缓存
    private Set<Class<?>> cachedWrapperClasses;
    
    // 扩展点名称到 Class 的映射
    private Map<String, Class<?>> extensionClasses; // volatile
    
    // 扩展点加载状态标志
    private volatile boolean extensionClassesInitied = false;
}    // 扩展点名称到 Class 的映射`
`#public class ExtensionLoader<T> {
    // 扩展点接口的 Class 对象
    private final Class<?> type;
    
    // 扩展点注入器(用于 IOC)
    private final ExtensionFactory objectFactory;
    
    // 扩展点实例缓存 (扩展名 -> 扩展实例)
    private final ConcurrentMap<String, Holder<Object>> cachedInstances = new ConcurrentHashMap<>();
    
    // 扩展点 Class 缓存 (扩展名 -> 扩展 Class)
    private final ConcurrentHashMap<String, Class<?>> cachedClasses = new ConcurrentHashMap<>();
    
    // 自适应扩展实例缓存
    private final Holder<Object> cachedAdaptiveInstance = new Holder<>();
    
    // 默认扩展名
    private String cachedDefaultName;
    
    // 缓存扩展点的 @Activate 注解信息
    private final Map<String, Object> cachedActivates = new ConcurrentHashMap<>();
    
    // 扩展点包装类缓存
    private Set<Class<?>> cachedWrapperClasses;
    
    // 扩展点名称到 Class 的映射
    private Map<String, Class<?>> extensionClasses; // volatile
    
    // 扩展点加载状态标志
    private volatile boolean extensionClassesInitied = false;
}    private Map<String, Class<?>> extensionClasses; // volatile`
`#public class ExtensionLoader<T> {
    // 扩展点接口的 Class 对象
    private final Class<?> type;
    
    // 扩展点注入器(用于 IOC)
    private final ExtensionFactory objectFactory;
    
    // 扩展点实例缓存 (扩展名 -> 扩展实例)
    private final ConcurrentMap<String, Holder<Object>> cachedInstances = new ConcurrentHashMap<>();
    
    // 扩展点 Class 缓存 (扩展名 -> 扩展 Class)
    private final ConcurrentHashMap<String, Class<?>> cachedClasses = new ConcurrentHashMap<>();
    
    // 自适应扩展实例缓存
    private final Holder<Object> cachedAdaptiveInstance = new Holder<>();
    
    // 默认扩展名
    private String cachedDefaultName;
    
    // 缓存扩展点的 @Activate 注解信息
    private final Map<String, Object> cachedActivates = new ConcurrentHashMap<>();
    
    // 扩展点包装类缓存
    private Set<Class<?>> cachedWrapperClasses;
    
    // 扩展点名称到 Class 的映射
    private Map<String, Class<?>> extensionClasses; // volatile
    
    // 扩展点加载状态标志
    private volatile boolean extensionClassesInitied = false;
}    `
`#public class ExtensionLoader<T> {
    // 扩展点接口的 Class 对象
    private final Class<?> type;
    
    // 扩展点注入器(用于 IOC)
    private final ExtensionFactory objectFactory;
    
    // 扩展点实例缓存 (扩展名 -> 扩展实例)
    private final ConcurrentMap<String, Holder<Object>> cachedInstances = new ConcurrentHashMap<>();
    
    // 扩展点 Class 缓存 (扩展名 -> 扩展 Class)
    private final ConcurrentHashMap<String, Class<?>> cachedClasses = new ConcurrentHashMap<>();
    
    // 自适应扩展实例缓存
    private final Holder<Object> cachedAdaptiveInstance = new Holder<>();
    
    // 默认扩展名
    private String cachedDefaultName;
    
    // 缓存扩展点的 @Activate 注解信息
    private final Map<String, Object> cachedActivates = new ConcurrentHashMap<>();
    
    // 扩展点包装类缓存
    private Set<Class<?>> cachedWrapperClasses;
    
    // 扩展点名称到 Class 的映射
    private Map<String, Class<?>> extensionClasses; // volatile
    
    // 扩展点加载状态标志
    private volatile boolean extensionClassesInitied = false;
}    // 扩展点加载状态标志`
`#public class ExtensionLoader<T> {
    // 扩展点接口的 Class 对象
    private final Class<?> type;
    
    // 扩展点注入器(用于 IOC)
    private final ExtensionFactory objectFactory;
    
    // 扩展点实例缓存 (扩展名 -> 扩展实例)
    private final ConcurrentMap<String, Holder<Object>> cachedInstances = new ConcurrentHashMap<>();
    
    // 扩展点 Class 缓存 (扩展名 -> 扩展 Class)
    private final ConcurrentHashMap<String, Class<?>> cachedClasses = new ConcurrentHashMap<>();
    
    // 自适应扩展实例缓存
    private final Holder<Object> cachedAdaptiveInstance = new Holder<>();
    
    // 默认扩展名
    private String cachedDefaultName;
    
    // 缓存扩展点的 @Activate 注解信息
    private final Map<String, Object> cachedActivates = new ConcurrentHashMap<>();
    
    // 扩展点包装类缓存
    private Set<Class<?>> cachedWrapperClasses;
    
    // 扩展点名称到 Class 的映射
    private Map<String, Class<?>> extensionClasses; // volatile
    
    // 扩展点加载状态标志
    private volatile boolean extensionClassesInitied = false;
}    private volatile boolean extensionClassesInitied = false;`
`#public class ExtensionLoader<T> {
    // 扩展点接口的 Class 对象
    private final Class<?> type;
    
    // 扩展点注入器(用于 IOC)
    private final ExtensionFactory objectFactory;
    
    // 扩展点实例缓存 (扩展名 -> 扩展实例)
    private final ConcurrentMap<String, Holder<Object>> cachedInstances = new ConcurrentHashMap<>();
    
    // 扩展点 Class 缓存 (扩展名 -> 扩展 Class)
    private final ConcurrentHashMap<String, Class<?>> cachedClasses = new ConcurrentHashMap<>();
    
    // 自适应扩展实例缓存
    private final Holder<Object> cachedAdaptiveInstance = new Holder<>();
    
    // 默认扩展名
    private String cachedDefaultName;
    
    // 缓存扩展点的 @Activate 注解信息
    private final Map<String, Object> cachedActivates = new ConcurrentHashMap<>();
    
    // 扩展点包装类缓存
    private Set<Class<?>> cachedWrapperClasses;
    
    // 扩展点名称到 Class 的映射
    private Map<String, Class<?>> extensionClasses; // volatile
    
    // 扩展点加载状态标志
    private volatile boolean extensionClassesInitied = false;
}}

3.2 ExtensionLoader 工作流程图

复制代码
flowchart TD
    A[调用getExtension方法] --> B{缓存中是否存在?}
    B -->|是| C[返回缓存实例]
    B -->|否| D[创建Holder对象并放入缓存]
    D --> E[双重检查锁]
    E --> F{再次检查缓存}
    F -->|已被其他线程创建| C
    F -->|否| G[调用createExtension方法]
    
    G --> H[getExtensionClasses获取所有扩展Class]
    H --> I[根据name查找对应的Class]
    I --> J{Class是否存在?}
    J -->|否| K[抛出IllegalStateException]
    J -->|是| L[通过反射创建实例]
    
    L --> M[injectExtension注入依赖]
    M --> N{是否有Wrapper类?}
    N -->|是| O[层层包装实例]
    O --> P[将最终实例放入缓存]
    N -->|否| P
    
    P --> Q[返回扩展实例]
    
    style A fill:#e1f5ff
    style G fill:#fff4e1
    style M fill:#ffe1f5
    style O fill:#f0ffe1
    style Q fill:#e1ffe1

3.3 getExtension 方法源码解析

这是获取扩展实例的入口方法:

java 复制代码
#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}/**`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
} * 根据名称获取扩展实例`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
} * @param name 扩展点名称(别名)`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
} * @return 扩展实例`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
} */`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}public T getExtension(String name) {`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}    if (StringUtils.isEmpty(name)) {`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}        throw new IllegalArgumentException("Extension name == null");`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}    }`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}    if ("true".equals(name)) {`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}        // 获取默认扩展实现`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}        return getDefaultExtension();`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}    }`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}    `
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}    // 1. 从缓存获取Holder对象`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}    final Holder<Object> holder = getOrCreateHolder(name);`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}    `
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}    // 2. 双重检查锁模式`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}    Object instance = holder.get();`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}    if (instance == null) {`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}        synchronized (holder) {`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}            instance = holder.get();`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}            if (instance == null) {`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}                // 3. 创建扩展实例`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}                instance = createExtension(name);`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}                // 4. 放入缓存`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}                holder.set(instance);`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}            }`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}        }`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}    }`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}    return (T) instance;`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}}`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}// 获取或创建Holder对象`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}private Holder<Object> getOrCreateHolder(String name) {`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}    Holder<Object> holder = cachedInstances.get(name);`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}    if (holder == null) {`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}        cachedInstances.putIfAbsent(name, new Holder<>());`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}        holder = cachedInstances.get(name);`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}    }`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}    return holder;`
`#/**
 * 根据名称获取扩展实例
 * @param name 扩展点名称(别名)
 * @return 扩展实例
 */
public T getExtension(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("Extension name == null");
    }
    if ("true".equals(name)) {
        // 获取默认扩展实现
        return getDefaultExtension();
    }
    
    // 1. 从缓存获取Holder对象
    final Holder<Object> holder = getOrCreateHolder(name);
    
    // 2. 双重检查锁模式
    Object instance = holder.get();
    if (instance == null) {
        synchronized (holder) {
            instance = holder.get();
            if (instance == null) {
                // 3. 创建扩展实例
                instance = createExtension(name);
                // 4. 放入缓存
                holder.set(instance);
            }
        }
    }
    return (T) instance;
}

// 获取或创建Holder对象
private Holder<Object> getOrCreateHolder(String name) {
    Holder<Object> holder = cachedInstances.get(name);
    if (holder == null) {
        cachedInstances.putIfAbsent(name, new Holder<>());
        holder = cachedInstances.get(name);
    }
    return holder;
}}

代码解读: 1. 懒加载 : 只有在第一次调用时才创建实例 2. 双重检查锁 : 保证线程安全,同时避免重复创建 3. Holder 模式: 使用 Holder 对象间接持有实例,便于实现线程安全的延迟初始化

3.4 createExtension 方法核心实现

这是扩展实例创建的核心方法,包含了 IOC 和 AOP 的实现:

java 复制代码
#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}/**`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
} * 创建扩展实例的核心方法`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
} */`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}private T createExtension(String name) {`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}    // 1. 获取所有扩展点的Class映射`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}    Class<?> clazz = getExtensionClasses().get(name);`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}    `
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}    if (clazz == null) {`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}        throw findException(name);`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}    }`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}    `
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}    try {`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}        // 2. 通过反射创建实例`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}        T instance = (T) EXTENSION_INSTANCES.get(clazz);`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}        if (instance == null) {`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}            instance = (T) EXTENSION_INSTANCES.get(clazz);`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}        }`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}        `
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}        // 3. IOC: 依赖注入`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}        injectExtension(instance);`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}        `
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}        // 4. AOP: 包装类处理`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}        Set<Class<?>> wrapperClasses = cachedWrapperClasses;`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}        if (CollectionUtils.isNotEmpty(wrapperClasses)) {`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}            for (Class<?> wrapperClass : wrapperClasses) {`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}                // 创建包装类实例,将当前实例作为构造参数`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}                if (wrapper == null `
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}                    || (ArrayUtils.contains(wrapper.matches(), name) `
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}                }`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}            }`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}        }`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}        `
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}        // 5. 初始化回调(如果实现了Lifecycle接口)`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}        initExtension(instance);`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}        `
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}        return instance;`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}    } catch (Throwable t) {`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}            type + ") couldn't be instantiated: " + t.getMessage(), t);`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}    }`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}}`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}/**`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
} * IOC: 依赖注入实现`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
} */`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}private T injectExtension(T instance) {`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}    if (objectFactory == null) {`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}        return instance;`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}    }`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}    `
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}    try {`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}        // 遍历所有setter方法`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}        for (Method method : instance.getClass().getMethods()) {`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}            if (!isSetter(method)) {`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}                continue;`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}            }`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}            `
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}            /**`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}             * 检查 DisableInject 注解`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}             * 如果有此注解,跳过该属性的注入`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}             */`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}            if (method.getAnnotation(DisableInject.class) != null) {`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}                continue;`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}            }`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}            `
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}            Class<?> pt = method.getParameterTypes()[0];`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}            if (ReflectUtils.isPrimitives(pt)) {`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}                continue;`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}            }`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}            `
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}            try {`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}                // 获取属性名称`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}                String property = getSetterProperty(method);`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}                // 从objectFactory获取对象`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}                Object object = objectFactory.getExtension(pt, property);`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}                if (object != null) {`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}                    // 反射调用setter方法注入依赖`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}                    method.invoke(instance, object);`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}                }`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}            } catch (Exception e) {`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}                logger.error("Failed to inject via method " + method.getName()`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}                    + " of interface " + type.getName() + ": " + e.getMessage(), e);`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}            }`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}        }`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}    } catch (Exception e) {`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}        logger.error(e.getMessage(), e);`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}    }`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}    return instance;`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}}`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}/**`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
} * 判断是否是setter方法`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
} * 方法名以set开头,参数个数为1,返回类型为void`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
} */`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}private boolean isSetter(Method method) {`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}    return method.getName().startsWith("set")`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}        && method.getParameterTypes().length == 1`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}        && Modifier.isPublic(method.getModifiers())`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}        && void.class.equals(method.getReturnType());`
`#/**
 * 创建扩展实例的核心方法
 */
private T createExtension(String name) {
    // 1. 获取所有扩展点的Class映射
    Class<?> clazz = getExtensionClasses().get(name);
    
    if (clazz == null) {
        throw findException(name);
    }
    
    try {
        // 2. 通过反射创建实例
        T instance = (T) EXTENSION_INSTANCES.get(clazz);
        if (instance == null) {
            EXTENSION_INSTANCES.putIfAbsent(clazz, clazz.getDeclaredConstructor().newInstance());
            instance = (T) EXTENSION_INSTANCES.get(clazz);
        }
        
        // 3. IOC: 依赖注入
        injectExtension(instance);
        
        // 4. AOP: 包装类处理
        Set<Class<?>> wrapperClasses = cachedWrapperClasses;
        if (CollectionUtils.isNotEmpty(wrapperClasses)) {
            for (Class<?> wrapperClass : wrapperClasses) {
                // 创建包装类实例,将当前实例作为构造参数
                Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class);
                if (wrapper == null 
                    || (ArrayUtils.contains(wrapper.matches(), name) 
                        && !ArrayUtils.contains(wrapper.mismatches(), name))) {
                    instance = (T) wrapperClass.getDeclaredConstructor(type).newInstance(instance);
                }
            }
        }
        
        // 5. 初始化回调(如果实现了Lifecycle接口)
        initExtension(instance);
        
        return instance;
    } catch (Throwable t) {
        throw new IllegalStateException("Extension instance (name: " + name + ", class: " +
            type + ") couldn't be instantiated: " + t.getMessage(), t);
    }
}

/**
 * IOC: 依赖注入实现
 */
private T injectExtension(T instance) {
    if (objectFactory == null) {
        return instance;
    }
    
    try {
        // 遍历所有setter方法
        for (Method method : instance.getClass().getMethods()) {
            if (!isSetter(method)) {
                continue;
            }
            
            /**
             * 检查 DisableInject 注解
             * 如果有此注解,跳过该属性的注入
             */
            if (method.getAnnotation(DisableInject.class) != null) {
                continue;
            }
            
            Class<?> pt = method.getParameterTypes()[0];
            if (ReflectUtils.isPrimitives(pt)) {
                continue;
            }
            
            try {
                // 获取属性名称
                String property = getSetterProperty(method);
                // 从objectFactory获取对象
                Object object = objectFactory.getExtension(pt, property);
                if (object != null) {
                    // 反射调用setter方法注入依赖
                    method.invoke(instance, object);
                }
            } catch (Exception e) {
                logger.error("Failed to inject via method " + method.getName()
                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return instance;
}

/**
 * 判断是否是setter方法
 * 方法名以set开头,参数个数为1,返回类型为void
 */
private boolean isSetter(Method method) {
    return method.getName().startsWith("set")
        && method.getParameterTypes().length == 1
        && Modifier.isPublic(method.getModifiers())
        && void.class.equals(method.getReturnType());
}}

代码解读: 1. 反射创建实例 : 使用 newInstance() 创建扩展对象 2. 依赖注入 : 遍历所有 setter 方法,通过 objectFactory 获取依赖对象并注入 3. 包装类处理 : 将实例层层包装,实现 AOP 功能 4. 异常处理: 详细的异常信息,便于调试

3.5 IOC 机制详解

Dubbo SPI 的 IOC 机制通过 setter 方法注入依赖,让我们通过一个例子来说明:

示例:

java 复制代码
#public interface Robot {
    void sayHello();
}

public class OptimusPrime implements Robot {
    private Weapon weapon; // 需要注入的依赖
    
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello() {
        System.out.println("I am Optimus Prime!");
        weapon.attack(); // 使用注入的weapon
    }
}

public interface Weapon {
    void attack();
}

public class Cannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("Cannon attack!");
    }
}public interface Robot {`
`#public interface Robot {
    void sayHello();
}

public class OptimusPrime implements Robot {
    private Weapon weapon; // 需要注入的依赖
    
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello() {
        System.out.println("I am Optimus Prime!");
        weapon.attack(); // 使用注入的weapon
    }
}

public interface Weapon {
    void attack();
}

public class Cannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("Cannon attack!");
    }
}    void sayHello();`
`#public interface Robot {
    void sayHello();
}

public class OptimusPrime implements Robot {
    private Weapon weapon; // 需要注入的依赖
    
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello() {
        System.out.println("I am Optimus Prime!");
        weapon.attack(); // 使用注入的weapon
    }
}

public interface Weapon {
    void attack();
}

public class Cannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("Cannon attack!");
    }
}}`
`#public interface Robot {
    void sayHello();
}

public class OptimusPrime implements Robot {
    private Weapon weapon; // 需要注入的依赖
    
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello() {
        System.out.println("I am Optimus Prime!");
        weapon.attack(); // 使用注入的weapon
    }
}

public interface Weapon {
    void attack();
}

public class Cannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("Cannon attack!");
    }
}`
`#public interface Robot {
    void sayHello();
}

public class OptimusPrime implements Robot {
    private Weapon weapon; // 需要注入的依赖
    
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello() {
        System.out.println("I am Optimus Prime!");
        weapon.attack(); // 使用注入的weapon
    }
}

public interface Weapon {
    void attack();
}

public class Cannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("Cannon attack!");
    }
}public class OptimusPrime implements Robot {`
`#public interface Robot {
    void sayHello();
}

public class OptimusPrime implements Robot {
    private Weapon weapon; // 需要注入的依赖
    
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello() {
        System.out.println("I am Optimus Prime!");
        weapon.attack(); // 使用注入的weapon
    }
}

public interface Weapon {
    void attack();
}

public class Cannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("Cannon attack!");
    }
}    private Weapon weapon; // 需要注入的依赖`
`#public interface Robot {
    void sayHello();
}

public class OptimusPrime implements Robot {
    private Weapon weapon; // 需要注入的依赖
    
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello() {
        System.out.println("I am Optimus Prime!");
        weapon.attack(); // 使用注入的weapon
    }
}

public interface Weapon {
    void attack();
}

public class Cannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("Cannon attack!");
    }
}    `
`#public interface Robot {
    void sayHello();
}

public class OptimusPrime implements Robot {
    private Weapon weapon; // 需要注入的依赖
    
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello() {
        System.out.println("I am Optimus Prime!");
        weapon.attack(); // 使用注入的weapon
    }
}

public interface Weapon {
    void attack();
}

public class Cannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("Cannon attack!");
    }
}    public void setWeapon(Weapon weapon) {`
`#public interface Robot {
    void sayHello();
}

public class OptimusPrime implements Robot {
    private Weapon weapon; // 需要注入的依赖
    
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello() {
        System.out.println("I am Optimus Prime!");
        weapon.attack(); // 使用注入的weapon
    }
}

public interface Weapon {
    void attack();
}

public class Cannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("Cannon attack!");
    }
}        this.weapon = weapon;`
`#public interface Robot {
    void sayHello();
}

public class OptimusPrime implements Robot {
    private Weapon weapon; // 需要注入的依赖
    
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello() {
        System.out.println("I am Optimus Prime!");
        weapon.attack(); // 使用注入的weapon
    }
}

public interface Weapon {
    void attack();
}

public class Cannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("Cannon attack!");
    }
}    }`
`#public interface Robot {
    void sayHello();
}

public class OptimusPrime implements Robot {
    private Weapon weapon; // 需要注入的依赖
    
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello() {
        System.out.println("I am Optimus Prime!");
        weapon.attack(); // 使用注入的weapon
    }
}

public interface Weapon {
    void attack();
}

public class Cannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("Cannon attack!");
    }
}    `
`#public interface Robot {
    void sayHello();
}

public class OptimusPrime implements Robot {
    private Weapon weapon; // 需要注入的依赖
    
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello() {
        System.out.println("I am Optimus Prime!");
        weapon.attack(); // 使用注入的weapon
    }
}

public interface Weapon {
    void attack();
}

public class Cannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("Cannon attack!");
    }
}    @Override`
`#public interface Robot {
    void sayHello();
}

public class OptimusPrime implements Robot {
    private Weapon weapon; // 需要注入的依赖
    
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello() {
        System.out.println("I am Optimus Prime!");
        weapon.attack(); // 使用注入的weapon
    }
}

public interface Weapon {
    void attack();
}

public class Cannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("Cannon attack!");
    }
}    public void sayHello() {`
`#public interface Robot {
    void sayHello();
}

public class OptimusPrime implements Robot {
    private Weapon weapon; // 需要注入的依赖
    
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello() {
        System.out.println("I am Optimus Prime!");
        weapon.attack(); // 使用注入的weapon
    }
}

public interface Weapon {
    void attack();
}

public class Cannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("Cannon attack!");
    }
}        System.out.println("I am Optimus Prime!");`
`#public interface Robot {
    void sayHello();
}

public class OptimusPrime implements Robot {
    private Weapon weapon; // 需要注入的依赖
    
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello() {
        System.out.println("I am Optimus Prime!");
        weapon.attack(); // 使用注入的weapon
    }
}

public interface Weapon {
    void attack();
}

public class Cannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("Cannon attack!");
    }
}        weapon.attack(); // 使用注入的weapon`
`#public interface Robot {
    void sayHello();
}

public class OptimusPrime implements Robot {
    private Weapon weapon; // 需要注入的依赖
    
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello() {
        System.out.println("I am Optimus Prime!");
        weapon.attack(); // 使用注入的weapon
    }
}

public interface Weapon {
    void attack();
}

public class Cannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("Cannon attack!");
    }
}    }`
`#public interface Robot {
    void sayHello();
}

public class OptimusPrime implements Robot {
    private Weapon weapon; // 需要注入的依赖
    
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello() {
        System.out.println("I am Optimus Prime!");
        weapon.attack(); // 使用注入的weapon
    }
}

public interface Weapon {
    void attack();
}

public class Cannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("Cannon attack!");
    }
}}`
`#public interface Robot {
    void sayHello();
}

public class OptimusPrime implements Robot {
    private Weapon weapon; // 需要注入的依赖
    
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello() {
        System.out.println("I am Optimus Prime!");
        weapon.attack(); // 使用注入的weapon
    }
}

public interface Weapon {
    void attack();
}

public class Cannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("Cannon attack!");
    }
}`
`#public interface Robot {
    void sayHello();
}

public class OptimusPrime implements Robot {
    private Weapon weapon; // 需要注入的依赖
    
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello() {
        System.out.println("I am Optimus Prime!");
        weapon.attack(); // 使用注入的weapon
    }
}

public interface Weapon {
    void attack();
}

public class Cannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("Cannon attack!");
    }
}public interface Weapon {`
`#public interface Robot {
    void sayHello();
}

public class OptimusPrime implements Robot {
    private Weapon weapon; // 需要注入的依赖
    
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello() {
        System.out.println("I am Optimus Prime!");
        weapon.attack(); // 使用注入的weapon
    }
}

public interface Weapon {
    void attack();
}

public class Cannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("Cannon attack!");
    }
}    void attack();`
`#public interface Robot {
    void sayHello();
}

public class OptimusPrime implements Robot {
    private Weapon weapon; // 需要注入的依赖
    
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello() {
        System.out.println("I am Optimus Prime!");
        weapon.attack(); // 使用注入的weapon
    }
}

public interface Weapon {
    void attack();
}

public class Cannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("Cannon attack!");
    }
}}`
`#public interface Robot {
    void sayHello();
}

public class OptimusPrime implements Robot {
    private Weapon weapon; // 需要注入的依赖
    
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello() {
        System.out.println("I am Optimus Prime!");
        weapon.attack(); // 使用注入的weapon
    }
}

public interface Weapon {
    void attack();
}

public class Cannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("Cannon attack!");
    }
}`
`#public interface Robot {
    void sayHello();
}

public class OptimusPrime implements Robot {
    private Weapon weapon; // 需要注入的依赖
    
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello() {
        System.out.println("I am Optimus Prime!");
        weapon.attack(); // 使用注入的weapon
    }
}

public interface Weapon {
    void attack();
}

public class Cannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("Cannon attack!");
    }
}public class Cannon implements Weapon {`
`#public interface Robot {
    void sayHello();
}

public class OptimusPrime implements Robot {
    private Weapon weapon; // 需要注入的依赖
    
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello() {
        System.out.println("I am Optimus Prime!");
        weapon.attack(); // 使用注入的weapon
    }
}

public interface Weapon {
    void attack();
}

public class Cannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("Cannon attack!");
    }
}    @Override`
`#public interface Robot {
    void sayHello();
}

public class OptimusPrime implements Robot {
    private Weapon weapon; // 需要注入的依赖
    
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello() {
        System.out.println("I am Optimus Prime!");
        weapon.attack(); // 使用注入的weapon
    }
}

public interface Weapon {
    void attack();
}

public class Cannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("Cannon attack!");
    }
}    public void attack() {`
`#public interface Robot {
    void sayHello();
}

public class OptimusPrime implements Robot {
    private Weapon weapon; // 需要注入的依赖
    
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello() {
        System.out.println("I am Optimus Prime!");
        weapon.attack(); // 使用注入的weapon
    }
}

public interface Weapon {
    void attack();
}

public class Cannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("Cannon attack!");
    }
}        System.out.println("Cannon attack!");`
`#public interface Robot {
    void sayHello();
}

public class OptimusPrime implements Robot {
    private Weapon weapon; // 需要注入的依赖
    
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello() {
        System.out.println("I am Optimus Prime!");
        weapon.attack(); // 使用注入的weapon
    }
}

public interface Weapon {
    void attack();
}

public class Cannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("Cannon attack!");
    }
}    }`
`#public interface Robot {
    void sayHello();
}

public class OptimusPrime implements Robot {
    private Weapon weapon; // 需要注入的依赖
    
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello() {
        System.out.println("I am Optimus Prime!");
        weapon.attack(); // 使用注入的weapon
    }
}

public interface Weapon {
    void attack();
}

public class Cannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("Cannon attack!");
    }
}}

配置文件:

META-INF/dubbo/com.example.Robot:

复制代码
optimusPrime=com.example.impl.OptimusPrime

META-INF/dubbo/com.example.Weapon:

复制代码
cannon=com.example.impl.Cannon

IOC 注入流程:

复制代码
sequenceDiagram
    participant Main
    participant EL as ExtensionLoader<Robot>
    participant EF as ExtensionFactory
    participant EL2 as ExtensionLoader<Weapon>
    
    Main->>EL: getExtension("optimusPrime")
    EL->>EL: createExtension("optimusPrime")
    EL->>EL: 创建OptimusPrime实例
    EL->>EL: injectExtension(instance)
    
    loop 遍历setter方法
        EL->>EL: 发现setWeapon方法
        EL->>EF: getExtension(Weapon.class, "weapon")
        EF->>EL2: getExtension("weapon")
        EL2->>EL2: 查找配置文件中的默认实现
        EL2-->>EF: 返回Cannon实例
        EF-->>EL: 返回Cannon实例
        EL->>EL: 反射调用setWeapon(cannon)
    end
    
    EL-->>Main: 返回注入完成的OptimusPrime实例

3.6 AOP 机制详解(Wrapper 类)

Dubbo SPI 通过 Wrapper 类实现 AOP 功能,Wrapper 类需要: 1. 实现扩展点接口 2. 持有一个扩展点接口的引用(通过构造函数注入)

示例:

java 复制代码
#// Wrapper类1: 日志记录
public class RobotWrapper1 implements Robot {
    private Robot robot;
    
    public RobotWrapper1(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        System.out.println("=== Before sayHello ===");
        robot.sayHello();
        System.out.println("=== After sayHello ===");
    }
}

// Wrapper类2: 性能监控
public class RobotWrapper2 implements Robot {
    private Robot robot;
    
    public RobotWrapper2(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        long start = System.currentTimeMillis();
        robot.sayHello();
        long end = System.currentTimeMillis();
        System.out.println("执行耗时: " + (end - start) + "ms");
    }
}// Wrapper类1: 日志记录`
`#// Wrapper类1: 日志记录
public class RobotWrapper1 implements Robot {
    private Robot robot;
    
    public RobotWrapper1(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        System.out.println("=== Before sayHello ===");
        robot.sayHello();
        System.out.println("=== After sayHello ===");
    }
}

// Wrapper类2: 性能监控
public class RobotWrapper2 implements Robot {
    private Robot robot;
    
    public RobotWrapper2(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        long start = System.currentTimeMillis();
        robot.sayHello();
        long end = System.currentTimeMillis();
        System.out.println("执行耗时: " + (end - start) + "ms");
    }
}public class RobotWrapper1 implements Robot {`
`#// Wrapper类1: 日志记录
public class RobotWrapper1 implements Robot {
    private Robot robot;
    
    public RobotWrapper1(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        System.out.println("=== Before sayHello ===");
        robot.sayHello();
        System.out.println("=== After sayHello ===");
    }
}

// Wrapper类2: 性能监控
public class RobotWrapper2 implements Robot {
    private Robot robot;
    
    public RobotWrapper2(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        long start = System.currentTimeMillis();
        robot.sayHello();
        long end = System.currentTimeMillis();
        System.out.println("执行耗时: " + (end - start) + "ms");
    }
}    private Robot robot;`
`#// Wrapper类1: 日志记录
public class RobotWrapper1 implements Robot {
    private Robot robot;
    
    public RobotWrapper1(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        System.out.println("=== Before sayHello ===");
        robot.sayHello();
        System.out.println("=== After sayHello ===");
    }
}

// Wrapper类2: 性能监控
public class RobotWrapper2 implements Robot {
    private Robot robot;
    
    public RobotWrapper2(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        long start = System.currentTimeMillis();
        robot.sayHello();
        long end = System.currentTimeMillis();
        System.out.println("执行耗时: " + (end - start) + "ms");
    }
}    `
`#// Wrapper类1: 日志记录
public class RobotWrapper1 implements Robot {
    private Robot robot;
    
    public RobotWrapper1(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        System.out.println("=== Before sayHello ===");
        robot.sayHello();
        System.out.println("=== After sayHello ===");
    }
}

// Wrapper类2: 性能监控
public class RobotWrapper2 implements Robot {
    private Robot robot;
    
    public RobotWrapper2(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        long start = System.currentTimeMillis();
        robot.sayHello();
        long end = System.currentTimeMillis();
        System.out.println("执行耗时: " + (end - start) + "ms");
    }
}    public RobotWrapper1(Robot robot) {`
`#// Wrapper类1: 日志记录
public class RobotWrapper1 implements Robot {
    private Robot robot;
    
    public RobotWrapper1(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        System.out.println("=== Before sayHello ===");
        robot.sayHello();
        System.out.println("=== After sayHello ===");
    }
}

// Wrapper类2: 性能监控
public class RobotWrapper2 implements Robot {
    private Robot robot;
    
    public RobotWrapper2(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        long start = System.currentTimeMillis();
        robot.sayHello();
        long end = System.currentTimeMillis();
        System.out.println("执行耗时: " + (end - start) + "ms");
    }
}        this.robot = robot;`
`#// Wrapper类1: 日志记录
public class RobotWrapper1 implements Robot {
    private Robot robot;
    
    public RobotWrapper1(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        System.out.println("=== Before sayHello ===");
        robot.sayHello();
        System.out.println("=== After sayHello ===");
    }
}

// Wrapper类2: 性能监控
public class RobotWrapper2 implements Robot {
    private Robot robot;
    
    public RobotWrapper2(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        long start = System.currentTimeMillis();
        robot.sayHello();
        long end = System.currentTimeMillis();
        System.out.println("执行耗时: " + (end - start) + "ms");
    }
}    }`
`#// Wrapper类1: 日志记录
public class RobotWrapper1 implements Robot {
    private Robot robot;
    
    public RobotWrapper1(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        System.out.println("=== Before sayHello ===");
        robot.sayHello();
        System.out.println("=== After sayHello ===");
    }
}

// Wrapper类2: 性能监控
public class RobotWrapper2 implements Robot {
    private Robot robot;
    
    public RobotWrapper2(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        long start = System.currentTimeMillis();
        robot.sayHello();
        long end = System.currentTimeMillis();
        System.out.println("执行耗时: " + (end - start) + "ms");
    }
}    `
`#// Wrapper类1: 日志记录
public class RobotWrapper1 implements Robot {
    private Robot robot;
    
    public RobotWrapper1(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        System.out.println("=== Before sayHello ===");
        robot.sayHello();
        System.out.println("=== After sayHello ===");
    }
}

// Wrapper类2: 性能监控
public class RobotWrapper2 implements Robot {
    private Robot robot;
    
    public RobotWrapper2(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        long start = System.currentTimeMillis();
        robot.sayHello();
        long end = System.currentTimeMillis();
        System.out.println("执行耗时: " + (end - start) + "ms");
    }
}    @Override`
`#// Wrapper类1: 日志记录
public class RobotWrapper1 implements Robot {
    private Robot robot;
    
    public RobotWrapper1(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        System.out.println("=== Before sayHello ===");
        robot.sayHello();
        System.out.println("=== After sayHello ===");
    }
}

// Wrapper类2: 性能监控
public class RobotWrapper2 implements Robot {
    private Robot robot;
    
    public RobotWrapper2(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        long start = System.currentTimeMillis();
        robot.sayHello();
        long end = System.currentTimeMillis();
        System.out.println("执行耗时: " + (end - start) + "ms");
    }
}    public void sayHello() {`
`#// Wrapper类1: 日志记录
public class RobotWrapper1 implements Robot {
    private Robot robot;
    
    public RobotWrapper1(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        System.out.println("=== Before sayHello ===");
        robot.sayHello();
        System.out.println("=== After sayHello ===");
    }
}

// Wrapper类2: 性能监控
public class RobotWrapper2 implements Robot {
    private Robot robot;
    
    public RobotWrapper2(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        long start = System.currentTimeMillis();
        robot.sayHello();
        long end = System.currentTimeMillis();
        System.out.println("执行耗时: " + (end - start) + "ms");
    }
}        System.out.println("=== Before sayHello ===");`
`#// Wrapper类1: 日志记录
public class RobotWrapper1 implements Robot {
    private Robot robot;
    
    public RobotWrapper1(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        System.out.println("=== Before sayHello ===");
        robot.sayHello();
        System.out.println("=== After sayHello ===");
    }
}

// Wrapper类2: 性能监控
public class RobotWrapper2 implements Robot {
    private Robot robot;
    
    public RobotWrapper2(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        long start = System.currentTimeMillis();
        robot.sayHello();
        long end = System.currentTimeMillis();
        System.out.println("执行耗时: " + (end - start) + "ms");
    }
}        robot.sayHello();`
`#// Wrapper类1: 日志记录
public class RobotWrapper1 implements Robot {
    private Robot robot;
    
    public RobotWrapper1(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        System.out.println("=== Before sayHello ===");
        robot.sayHello();
        System.out.println("=== After sayHello ===");
    }
}

// Wrapper类2: 性能监控
public class RobotWrapper2 implements Robot {
    private Robot robot;
    
    public RobotWrapper2(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        long start = System.currentTimeMillis();
        robot.sayHello();
        long end = System.currentTimeMillis();
        System.out.println("执行耗时: " + (end - start) + "ms");
    }
}        System.out.println("=== After sayHello ===");`
`#// Wrapper类1: 日志记录
public class RobotWrapper1 implements Robot {
    private Robot robot;
    
    public RobotWrapper1(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        System.out.println("=== Before sayHello ===");
        robot.sayHello();
        System.out.println("=== After sayHello ===");
    }
}

// Wrapper类2: 性能监控
public class RobotWrapper2 implements Robot {
    private Robot robot;
    
    public RobotWrapper2(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        long start = System.currentTimeMillis();
        robot.sayHello();
        long end = System.currentTimeMillis();
        System.out.println("执行耗时: " + (end - start) + "ms");
    }
}    }`
`#// Wrapper类1: 日志记录
public class RobotWrapper1 implements Robot {
    private Robot robot;
    
    public RobotWrapper1(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        System.out.println("=== Before sayHello ===");
        robot.sayHello();
        System.out.println("=== After sayHello ===");
    }
}

// Wrapper类2: 性能监控
public class RobotWrapper2 implements Robot {
    private Robot robot;
    
    public RobotWrapper2(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        long start = System.currentTimeMillis();
        robot.sayHello();
        long end = System.currentTimeMillis();
        System.out.println("执行耗时: " + (end - start) + "ms");
    }
}}`
`#// Wrapper类1: 日志记录
public class RobotWrapper1 implements Robot {
    private Robot robot;
    
    public RobotWrapper1(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        System.out.println("=== Before sayHello ===");
        robot.sayHello();
        System.out.println("=== After sayHello ===");
    }
}

// Wrapper类2: 性能监控
public class RobotWrapper2 implements Robot {
    private Robot robot;
    
    public RobotWrapper2(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        long start = System.currentTimeMillis();
        robot.sayHello();
        long end = System.currentTimeMillis();
        System.out.println("执行耗时: " + (end - start) + "ms");
    }
}`
`#// Wrapper类1: 日志记录
public class RobotWrapper1 implements Robot {
    private Robot robot;
    
    public RobotWrapper1(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        System.out.println("=== Before sayHello ===");
        robot.sayHello();
        System.out.println("=== After sayHello ===");
    }
}

// Wrapper类2: 性能监控
public class RobotWrapper2 implements Robot {
    private Robot robot;
    
    public RobotWrapper2(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        long start = System.currentTimeMillis();
        robot.sayHello();
        long end = System.currentTimeMillis();
        System.out.println("执行耗时: " + (end - start) + "ms");
    }
}// Wrapper类2: 性能监控`
`#// Wrapper类1: 日志记录
public class RobotWrapper1 implements Robot {
    private Robot robot;
    
    public RobotWrapper1(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        System.out.println("=== Before sayHello ===");
        robot.sayHello();
        System.out.println("=== After sayHello ===");
    }
}

// Wrapper类2: 性能监控
public class RobotWrapper2 implements Robot {
    private Robot robot;
    
    public RobotWrapper2(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        long start = System.currentTimeMillis();
        robot.sayHello();
        long end = System.currentTimeMillis();
        System.out.println("执行耗时: " + (end - start) + "ms");
    }
}public class RobotWrapper2 implements Robot {`
`#// Wrapper类1: 日志记录
public class RobotWrapper1 implements Robot {
    private Robot robot;
    
    public RobotWrapper1(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        System.out.println("=== Before sayHello ===");
        robot.sayHello();
        System.out.println("=== After sayHello ===");
    }
}

// Wrapper类2: 性能监控
public class RobotWrapper2 implements Robot {
    private Robot robot;
    
    public RobotWrapper2(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        long start = System.currentTimeMillis();
        robot.sayHello();
        long end = System.currentTimeMillis();
        System.out.println("执行耗时: " + (end - start) + "ms");
    }
}    private Robot robot;`
`#// Wrapper类1: 日志记录
public class RobotWrapper1 implements Robot {
    private Robot robot;
    
    public RobotWrapper1(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        System.out.println("=== Before sayHello ===");
        robot.sayHello();
        System.out.println("=== After sayHello ===");
    }
}

// Wrapper类2: 性能监控
public class RobotWrapper2 implements Robot {
    private Robot robot;
    
    public RobotWrapper2(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        long start = System.currentTimeMillis();
        robot.sayHello();
        long end = System.currentTimeMillis();
        System.out.println("执行耗时: " + (end - start) + "ms");
    }
}    `
`#// Wrapper类1: 日志记录
public class RobotWrapper1 implements Robot {
    private Robot robot;
    
    public RobotWrapper1(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        System.out.println("=== Before sayHello ===");
        robot.sayHello();
        System.out.println("=== After sayHello ===");
    }
}

// Wrapper类2: 性能监控
public class RobotWrapper2 implements Robot {
    private Robot robot;
    
    public RobotWrapper2(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        long start = System.currentTimeMillis();
        robot.sayHello();
        long end = System.currentTimeMillis();
        System.out.println("执行耗时: " + (end - start) + "ms");
    }
}    public RobotWrapper2(Robot robot) {`
`#// Wrapper类1: 日志记录
public class RobotWrapper1 implements Robot {
    private Robot robot;
    
    public RobotWrapper1(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        System.out.println("=== Before sayHello ===");
        robot.sayHello();
        System.out.println("=== After sayHello ===");
    }
}

// Wrapper类2: 性能监控
public class RobotWrapper2 implements Robot {
    private Robot robot;
    
    public RobotWrapper2(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        long start = System.currentTimeMillis();
        robot.sayHello();
        long end = System.currentTimeMillis();
        System.out.println("执行耗时: " + (end - start) + "ms");
    }
}        this.robot = robot;`
`#// Wrapper类1: 日志记录
public class RobotWrapper1 implements Robot {
    private Robot robot;
    
    public RobotWrapper1(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        System.out.println("=== Before sayHello ===");
        robot.sayHello();
        System.out.println("=== After sayHello ===");
    }
}

// Wrapper类2: 性能监控
public class RobotWrapper2 implements Robot {
    private Robot robot;
    
    public RobotWrapper2(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        long start = System.currentTimeMillis();
        robot.sayHello();
        long end = System.currentTimeMillis();
        System.out.println("执行耗时: " + (end - start) + "ms");
    }
}    }`
`#// Wrapper类1: 日志记录
public class RobotWrapper1 implements Robot {
    private Robot robot;
    
    public RobotWrapper1(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        System.out.println("=== Before sayHello ===");
        robot.sayHello();
        System.out.println("=== After sayHello ===");
    }
}

// Wrapper类2: 性能监控
public class RobotWrapper2 implements Robot {
    private Robot robot;
    
    public RobotWrapper2(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        long start = System.currentTimeMillis();
        robot.sayHello();
        long end = System.currentTimeMillis();
        System.out.println("执行耗时: " + (end - start) + "ms");
    }
}    `
`#// Wrapper类1: 日志记录
public class RobotWrapper1 implements Robot {
    private Robot robot;
    
    public RobotWrapper1(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        System.out.println("=== Before sayHello ===");
        robot.sayHello();
        System.out.println("=== After sayHello ===");
    }
}

// Wrapper类2: 性能监控
public class RobotWrapper2 implements Robot {
    private Robot robot;
    
    public RobotWrapper2(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        long start = System.currentTimeMillis();
        robot.sayHello();
        long end = System.currentTimeMillis();
        System.out.println("执行耗时: " + (end - start) + "ms");
    }
}    @Override`
`#// Wrapper类1: 日志记录
public class RobotWrapper1 implements Robot {
    private Robot robot;
    
    public RobotWrapper1(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        System.out.println("=== Before sayHello ===");
        robot.sayHello();
        System.out.println("=== After sayHello ===");
    }
}

// Wrapper类2: 性能监控
public class RobotWrapper2 implements Robot {
    private Robot robot;
    
    public RobotWrapper2(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        long start = System.currentTimeMillis();
        robot.sayHello();
        long end = System.currentTimeMillis();
        System.out.println("执行耗时: " + (end - start) + "ms");
    }
}    public void sayHello() {`
`#// Wrapper类1: 日志记录
public class RobotWrapper1 implements Robot {
    private Robot robot;
    
    public RobotWrapper1(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        System.out.println("=== Before sayHello ===");
        robot.sayHello();
        System.out.println("=== After sayHello ===");
    }
}

// Wrapper类2: 性能监控
public class RobotWrapper2 implements Robot {
    private Robot robot;
    
    public RobotWrapper2(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        long start = System.currentTimeMillis();
        robot.sayHello();
        long end = System.currentTimeMillis();
        System.out.println("执行耗时: " + (end - start) + "ms");
    }
}        long start = System.currentTimeMillis();`
`#// Wrapper类1: 日志记录
public class RobotWrapper1 implements Robot {
    private Robot robot;
    
    public RobotWrapper1(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        System.out.println("=== Before sayHello ===");
        robot.sayHello();
        System.out.println("=== After sayHello ===");
    }
}

// Wrapper类2: 性能监控
public class RobotWrapper2 implements Robot {
    private Robot robot;
    
    public RobotWrapper2(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        long start = System.currentTimeMillis();
        robot.sayHello();
        long end = System.currentTimeMillis();
        System.out.println("执行耗时: " + (end - start) + "ms");
    }
}        robot.sayHello();`
`#// Wrapper类1: 日志记录
public class RobotWrapper1 implements Robot {
    private Robot robot;
    
    public RobotWrapper1(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        System.out.println("=== Before sayHello ===");
        robot.sayHello();
        System.out.println("=== After sayHello ===");
    }
}

// Wrapper类2: 性能监控
public class RobotWrapper2 implements Robot {
    private Robot robot;
    
    public RobotWrapper2(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        long start = System.currentTimeMillis();
        robot.sayHello();
        long end = System.currentTimeMillis();
        System.out.println("执行耗时: " + (end - start) + "ms");
    }
}        long end = System.currentTimeMillis();`
`#// Wrapper类1: 日志记录
public class RobotWrapper1 implements Robot {
    private Robot robot;
    
    public RobotWrapper1(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        System.out.println("=== Before sayHello ===");
        robot.sayHello();
        System.out.println("=== After sayHello ===");
    }
}

// Wrapper类2: 性能监控
public class RobotWrapper2 implements Robot {
    private Robot robot;
    
    public RobotWrapper2(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        long start = System.currentTimeMillis();
        robot.sayHello();
        long end = System.currentTimeMillis();
        System.out.println("执行耗时: " + (end - start) + "ms");
    }
}        System.out.println("执行耗时: " + (end - start) + "ms");`
`#// Wrapper类1: 日志记录
public class RobotWrapper1 implements Robot {
    private Robot robot;
    
    public RobotWrapper1(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        System.out.println("=== Before sayHello ===");
        robot.sayHello();
        System.out.println("=== After sayHello ===");
    }
}

// Wrapper类2: 性能监控
public class RobotWrapper2 implements Robot {
    private Robot robot;
    
    public RobotWrapper2(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        long start = System.currentTimeMillis();
        robot.sayHello();
        long end = System.currentTimeMillis();
        System.out.println("执行耗时: " + (end - start) + "ms");
    }
}    }`
`#// Wrapper类1: 日志记录
public class RobotWrapper1 implements Robot {
    private Robot robot;
    
    public RobotWrapper1(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        System.out.println("=== Before sayHello ===");
        robot.sayHello();
        System.out.println("=== After sayHello ===");
    }
}

// Wrapper类2: 性能监控
public class RobotWrapper2 implements Robot {
    private Robot robot;
    
    public RobotWrapper2(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello() {
        long start = System.currentTimeMillis();
        robot.sayHello();
        long end = System.currentTimeMillis();
        System.out.println("执行耗时: " + (end - start) + "ms");
    }
}}

配置文件:

复制代码
optimusPrime=com.example.impl.OptimusPrime
wrapper1=com.example.wrapper.RobotWrapper1
wrapper2=com.example.wrapper.RobotWrapper2

Wrapper 类识别规则:

java 复制代码
#// 判断是否是Wrapper类
private boolean isWrapperClass(Class<?> clazz) {
    try {
        // 检查是否有以扩展点接口为参数的构造函数
        clazz.getConstructor(type);
        return true;
    } catch (NoSuchMethodException e) {
        return false;
    }
}// 判断是否是Wrapper类`
`#// 判断是否是Wrapper类
private boolean isWrapperClass(Class<?> clazz) {
    try {
        // 检查是否有以扩展点接口为参数的构造函数
        clazz.getConstructor(type);
        return true;
    } catch (NoSuchMethodException e) {
        return false;
    }
}private boolean isWrapperClass(Class<?> clazz) {`
`#// 判断是否是Wrapper类
private boolean isWrapperClass(Class<?> clazz) {
    try {
        // 检查是否有以扩展点接口为参数的构造函数
        clazz.getConstructor(type);
        return true;
    } catch (NoSuchMethodException e) {
        return false;
    }
}    try {`
`#// 判断是否是Wrapper类
private boolean isWrapperClass(Class<?> clazz) {
    try {
        // 检查是否有以扩展点接口为参数的构造函数
        clazz.getConstructor(type);
        return true;
    } catch (NoSuchMethodException e) {
        return false;
    }
}        // 检查是否有以扩展点接口为参数的构造函数`
`#// 判断是否是Wrapper类
private boolean isWrapperClass(Class<?> clazz) {
    try {
        // 检查是否有以扩展点接口为参数的构造函数
        clazz.getConstructor(type);
        return true;
    } catch (NoSuchMethodException e) {
        return false;
    }
}        clazz.getConstructor(type);`
`#// 判断是否是Wrapper类
private boolean isWrapperClass(Class<?> clazz) {
    try {
        // 检查是否有以扩展点接口为参数的构造函数
        clazz.getConstructor(type);
        return true;
    } catch (NoSuchMethodException e) {
        return false;
    }
}        return true;`
`#// 判断是否是Wrapper类
private boolean isWrapperClass(Class<?> clazz) {
    try {
        // 检查是否有以扩展点接口为参数的构造函数
        clazz.getConstructor(type);
        return true;
    } catch (NoSuchMethodException e) {
        return false;
    }
}    } catch (NoSuchMethodException e) {`
`#// 判断是否是Wrapper类
private boolean isWrapperClass(Class<?> clazz) {
    try {
        // 检查是否有以扩展点接口为参数的构造函数
        clazz.getConstructor(type);
        return true;
    } catch (NoSuchMethodException e) {
        return false;
    }
}        return false;`
`#// 判断是否是Wrapper类
private boolean isWrapperClass(Class<?> clazz) {
    try {
        // 检查是否有以扩展点接口为参数的构造函数
        clazz.getConstructor(type);
        return true;
    } catch (NoSuchMethodException e) {
        return false;
    }
}    }`
`#// 判断是否是Wrapper类
private boolean isWrapperClass(Class<?> clazz) {
    try {
        // 检查是否有以扩展点接口为参数的构造函数
        clazz.getConstructor(type);
        return true;
    } catch (NoSuchMethodException e) {
        return false;
    }
}}

包装执行顺序:

复制代码
graph LR
    A[Client] --> B[Wrapper2<br/>性能监控]
    B --> C[Wrapper1<br/>日志记录]
    C --> D[OptimusPrime<br/>实际实现]
    
    style A fill:#e1f5ff
    style D fill:#ffe1f5
    style B fill:#f0ffe1
    style C fill:#fff4e1

四、自适应扩展(Adaptive Extension)

4.1 自适应扩展概述

自适应扩展是 Dubbo SPI 的核心特性之一,它可以根据运行时参数动态选择具体的扩展实现。

核心思想: 通过 URL 参数传递扩展名,在运行时决定使用哪个实现。

4.2 @Adaptive 注解

@Adaptive 注解可以标注在: 1. 类上 : 该类为自适应扩展类(手动实现) 2. 方法上: 自动生成自适应扩展类的代理方法

示例接口:

java 复制代码
#@SPI("default")
public interface Robot {
    @Adaptive({ "robot.type" }) // 指定从URL的robot.type参数获取扩展名
    void sayHello(URL url);
}@SPI("default")`
`#@SPI("default")
public interface Robot {
    @Adaptive({ "robot.type" }) // 指定从URL的robot.type参数获取扩展名
    void sayHello(URL url);
}public interface Robot {`
`#@SPI("default")
public interface Robot {
    @Adaptive({ "robot.type" }) // 指定从URL的robot.type参数获取扩展名
    void sayHello(URL url);
}    @Adaptive({ "robot.type" }) // 指定从URL的robot.type参数获取扩展名`
`#@SPI("default")
public interface Robot {
    @Adaptive({ "robot.type" }) // 指定从URL的robot.type参数获取扩展名
    void sayHello(URL url);
}    void sayHello(URL url);`
`#@SPI("default")
public interface Robot {
    @Adaptive({ "robot.type" }) // 指定从URL的robot.type参数获取扩展名
    void sayHello(URL url);
}}

4.3 自动生成的自适应扩展类

Dubbo 会在运行时动态生成代理类,生成逻辑位于 ExtensionLoader.createAdaptiveExtensionClass():

java 复制代码
#/**
 * 动态生成自适应扩展类
 */
private Class<?> createAdaptiveExtensionClass() {
    // 生成代理类源代码
    String code = new AdaptiveClassCodeGenerator(type, cachedDefaultName).generate();
    
    // 获取类加载器
    ClassLoader classLoader = findClassLoader();
    
    // 编译源代码
    Compiler compiler = getExtensionLoader(Compiler.class).getAdaptiveExtension();
    return compiler.compile(code, classLoader);
}/**`
`#/**
 * 动态生成自适应扩展类
 */
private Class<?> createAdaptiveExtensionClass() {
    // 生成代理类源代码
    String code = new AdaptiveClassCodeGenerator(type, cachedDefaultName).generate();
    
    // 获取类加载器
    ClassLoader classLoader = findClassLoader();
    
    // 编译源代码
    Compiler compiler = getExtensionLoader(Compiler.class).getAdaptiveExtension();
    return compiler.compile(code, classLoader);
} * 动态生成自适应扩展类`
`#/**
 * 动态生成自适应扩展类
 */
private Class<?> createAdaptiveExtensionClass() {
    // 生成代理类源代码
    String code = new AdaptiveClassCodeGenerator(type, cachedDefaultName).generate();
    
    // 获取类加载器
    ClassLoader classLoader = findClassLoader();
    
    // 编译源代码
    Compiler compiler = getExtensionLoader(Compiler.class).getAdaptiveExtension();
    return compiler.compile(code, classLoader);
} */`
`#/**
 * 动态生成自适应扩展类
 */
private Class<?> createAdaptiveExtensionClass() {
    // 生成代理类源代码
    String code = new AdaptiveClassCodeGenerator(type, cachedDefaultName).generate();
    
    // 获取类加载器
    ClassLoader classLoader = findClassLoader();
    
    // 编译源代码
    Compiler compiler = getExtensionLoader(Compiler.class).getAdaptiveExtension();
    return compiler.compile(code, classLoader);
}private Class<?> createAdaptiveExtensionClass() {`
`#/**
 * 动态生成自适应扩展类
 */
private Class<?> createAdaptiveExtensionClass() {
    // 生成代理类源代码
    String code = new AdaptiveClassCodeGenerator(type, cachedDefaultName).generate();
    
    // 获取类加载器
    ClassLoader classLoader = findClassLoader();
    
    // 编译源代码
    Compiler compiler = getExtensionLoader(Compiler.class).getAdaptiveExtension();
    return compiler.compile(code, classLoader);
}    // 生成代理类源代码`
`#/**
 * 动态生成自适应扩展类
 */
private Class<?> createAdaptiveExtensionClass() {
    // 生成代理类源代码
    String code = new AdaptiveClassCodeGenerator(type, cachedDefaultName).generate();
    
    // 获取类加载器
    ClassLoader classLoader = findClassLoader();
    
    // 编译源代码
    Compiler compiler = getExtensionLoader(Compiler.class).getAdaptiveExtension();
    return compiler.compile(code, classLoader);
}    String code = new AdaptiveClassCodeGenerator(type, cachedDefaultName).generate();`
`#/**
 * 动态生成自适应扩展类
 */
private Class<?> createAdaptiveExtensionClass() {
    // 生成代理类源代码
    String code = new AdaptiveClassCodeGenerator(type, cachedDefaultName).generate();
    
    // 获取类加载器
    ClassLoader classLoader = findClassLoader();
    
    // 编译源代码
    Compiler compiler = getExtensionLoader(Compiler.class).getAdaptiveExtension();
    return compiler.compile(code, classLoader);
}    `
`#/**
 * 动态生成自适应扩展类
 */
private Class<?> createAdaptiveExtensionClass() {
    // 生成代理类源代码
    String code = new AdaptiveClassCodeGenerator(type, cachedDefaultName).generate();
    
    // 获取类加载器
    ClassLoader classLoader = findClassLoader();
    
    // 编译源代码
    Compiler compiler = getExtensionLoader(Compiler.class).getAdaptiveExtension();
    return compiler.compile(code, classLoader);
}    // 获取类加载器`
`#/**
 * 动态生成自适应扩展类
 */
private Class<?> createAdaptiveExtensionClass() {
    // 生成代理类源代码
    String code = new AdaptiveClassCodeGenerator(type, cachedDefaultName).generate();
    
    // 获取类加载器
    ClassLoader classLoader = findClassLoader();
    
    // 编译源代码
    Compiler compiler = getExtensionLoader(Compiler.class).getAdaptiveExtension();
    return compiler.compile(code, classLoader);
}    ClassLoader classLoader = findClassLoader();`
`#/**
 * 动态生成自适应扩展类
 */
private Class<?> createAdaptiveExtensionClass() {
    // 生成代理类源代码
    String code = new AdaptiveClassCodeGenerator(type, cachedDefaultName).generate();
    
    // 获取类加载器
    ClassLoader classLoader = findClassLoader();
    
    // 编译源代码
    Compiler compiler = getExtensionLoader(Compiler.class).getAdaptiveExtension();
    return compiler.compile(code, classLoader);
}    `
`#/**
 * 动态生成自适应扩展类
 */
private Class<?> createAdaptiveExtensionClass() {
    // 生成代理类源代码
    String code = new AdaptiveClassCodeGenerator(type, cachedDefaultName).generate();
    
    // 获取类加载器
    ClassLoader classLoader = findClassLoader();
    
    // 编译源代码
    Compiler compiler = getExtensionLoader(Compiler.class).getAdaptiveExtension();
    return compiler.compile(code, classLoader);
}    // 编译源代码`
`#/**
 * 动态生成自适应扩展类
 */
private Class<?> createAdaptiveExtensionClass() {
    // 生成代理类源代码
    String code = new AdaptiveClassCodeGenerator(type, cachedDefaultName).generate();
    
    // 获取类加载器
    ClassLoader classLoader = findClassLoader();
    
    // 编译源代码
    Compiler compiler = getExtensionLoader(Compiler.class).getAdaptiveExtension();
    return compiler.compile(code, classLoader);
}    Compiler compiler = getExtensionLoader(Compiler.class).getAdaptiveExtension();`
`#/**
 * 动态生成自适应扩展类
 */
private Class<?> createAdaptiveExtensionClass() {
    // 生成代理类源代码
    String code = new AdaptiveClassCodeGenerator(type, cachedDefaultName).generate();
    
    // 获取类加载器
    ClassLoader classLoader = findClassLoader();
    
    // 编译源代码
    Compiler compiler = getExtensionLoader(Compiler.class).getAdaptiveExtension();
    return compiler.compile(code, classLoader);
}    return compiler.compile(code, classLoader);`
`#/**
 * 动态生成自适应扩展类
 */
private Class<?> createAdaptiveExtensionClass() {
    // 生成代理类源代码
    String code = new AdaptiveClassCodeGenerator(type, cachedDefaultName).generate();
    
    // 获取类加载器
    ClassLoader classLoader = findClassLoader();
    
    // 编译源代码
    Compiler compiler = getExtensionLoader(Compiler.class).getAdaptiveExtension();
    return compiler.compile(code, classLoader);
}}

生成的代理类示例:

java 复制代码
#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}package com.example;`
`#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}`
`#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}import org.apache.dubbo.common.extension.ExtensionLoader;`
`#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}import org.apache.dubbo.common.URL;`
`#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}`
`#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}public class Robot$Adaptive implements com.example.Robot {`
`#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}    public void sayHello(URL url) {`
`#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}        if (url == null) {`
`#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}            throw new IllegalArgumentException("url == null");`
`#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}        }`
`#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}        `
`#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}        // 1. 从URL获取扩展名`
`#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}        String extName = url.getParameter("robot.type");`
`#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}        if (extName == null) {`
`#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}            // 使用默认值`
`#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}            extName = "default";`
`#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}        }`
`#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}        `
`#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}        if (extName == null) {`
`#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}            throw new IllegalStateException(`
`#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}                "Failed to get extension (com.example.Robot) name from url (" + url.toString() `
`#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}                + ") use keys([robot.type])");`
`#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}        }`
`#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}        `
`#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}        // 2. 根据扩展名获取实际实现`
`#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}        com.example.Robot extension = `
`#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)`
`#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}                .getExtension(extName);`
`#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}        `
`#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}        // 3. 调用实际实现的方法`
`#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}        extension.sayHello(url);`
`#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}    }`
`#package com.example;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.URL;

public class Robot$Adaptive implements com.example.Robot {
    public void sayHello(URL url) {
        if (url == null) {
            throw new IllegalArgumentException("url == null");
        }
        
        // 1. 从URL获取扩展名
        String extName = url.getParameter("robot.type");
        if (extName == null) {
            // 使用默认值
            extName = "default";
        }
        
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (com.example.Robot) name from url (" + url.toString() 
                + ") use keys([robot.type])");
        }
        
        // 2. 根据扩展名获取实际实现
        com.example.Robot extension = 
            (com.example.Robot) ExtensionLoader.getExtensionLoader(com.example.Robot.class)
                .getExtension(extName);
        
        // 3. 调用实际实现的方法
        extension.sayHello(url);
    }
}}

4.4 自适应扩展工作流程图

复制代码
flowchart TD
    A[调用getAdaptiveExtension] --> B{缓存是否存在?}
    B -->|是| C[返回缓存实例]
    B -->|否| D[双重检查锁]
    D --> E[createAdaptiveExtension]
    
    E --> F[getAdaptiveExtensionClass]
    F --> G{是否有@Adaptive注解的类?}
    G -->|是| H[返回该类]
    G -->|否| I[createAdaptiveExtensionClass]
    
    I --> J[AdaptiveClassCodeGenerator.generate]
    J --> K[生成Java代理类源代码]
    K --> L[Compiler.compile]
    L --> M[编译成Class对象]
    
    M --> N[通过反射创建实例]
    N --> O[injectExtension注入依赖]
    O --> P[放入缓存]
    P --> Q[返回自适应实例]
    
    style A fill:#e1f5ff
    style I fill:#fff4e1
    style K fill:#ffe1f5
    style Q fill:#e1ffe1

4.5 @Adaptive 注解参数映射规则

@Adaptive 注解的参数决定了从 URL 的哪个键获取扩展名:

java 复制代码
#@Adaptive({"key1", "key2"}) // 依次尝试 key1, key2, 使用第一个非空值@Adaptive({"key1", "key2"}) // 依次尝试 key1, key2, 使用第一个非空值

查找顺序:

  1. 尝试从 URL 获取 key1 对应的值
  2. 如果为空,尝试获取 key2 对应的值
  3. 如果都为空,使用接口 @SPI 注解指定的默认值
  4. 如果没有默认值,抛出异常

示例:

java 复制代码
#@SPI("default")
public interface Robot {
    @Adaptive({"robot.type", "robot"})
    void sayHello(URL url);
}

// URL: dubbo://localhost:20880?robot.type=optimusPrime
// -> 使用 "optimusPrime" 扩展

// URL: dubbo://localhost:20880?robot=bumblebee
// -> 使用 "bumblebee" 扩展

// URL: dubbo://localhost:20880
// -> 使用 "default" 扩展@SPI("default")`
`#@SPI("default")
public interface Robot {
    @Adaptive({"robot.type", "robot"})
    void sayHello(URL url);
}

// URL: dubbo://localhost:20880?robot.type=optimusPrime
// -> 使用 "optimusPrime" 扩展

// URL: dubbo://localhost:20880?robot=bumblebee
// -> 使用 "bumblebee" 扩展

// URL: dubbo://localhost:20880
// -> 使用 "default" 扩展public interface Robot {`
`#@SPI("default")
public interface Robot {
    @Adaptive({"robot.type", "robot"})
    void sayHello(URL url);
}

// URL: dubbo://localhost:20880?robot.type=optimusPrime
// -> 使用 "optimusPrime" 扩展

// URL: dubbo://localhost:20880?robot=bumblebee
// -> 使用 "bumblebee" 扩展

// URL: dubbo://localhost:20880
// -> 使用 "default" 扩展    @Adaptive({"robot.type", "robot"})`
`#@SPI("default")
public interface Robot {
    @Adaptive({"robot.type", "robot"})
    void sayHello(URL url);
}

// URL: dubbo://localhost:20880?robot.type=optimusPrime
// -> 使用 "optimusPrime" 扩展

// URL: dubbo://localhost:20880?robot=bumblebee
// -> 使用 "bumblebee" 扩展

// URL: dubbo://localhost:20880
// -> 使用 "default" 扩展    void sayHello(URL url);`
`#@SPI("default")
public interface Robot {
    @Adaptive({"robot.type", "robot"})
    void sayHello(URL url);
}

// URL: dubbo://localhost:20880?robot.type=optimusPrime
// -> 使用 "optimusPrime" 扩展

// URL: dubbo://localhost:20880?robot=bumblebee
// -> 使用 "bumblebee" 扩展

// URL: dubbo://localhost:20880
// -> 使用 "default" 扩展}`
`#@SPI("default")
public interface Robot {
    @Adaptive({"robot.type", "robot"})
    void sayHello(URL url);
}

// URL: dubbo://localhost:20880?robot.type=optimusPrime
// -> 使用 "optimusPrime" 扩展

// URL: dubbo://localhost:20880?robot=bumblebee
// -> 使用 "bumblebee" 扩展

// URL: dubbo://localhost:20880
// -> 使用 "default" 扩展`
`#@SPI("default")
public interface Robot {
    @Adaptive({"robot.type", "robot"})
    void sayHello(URL url);
}

// URL: dubbo://localhost:20880?robot.type=optimusPrime
// -> 使用 "optimusPrime" 扩展

// URL: dubbo://localhost:20880?robot=bumblebee
// -> 使用 "bumblebee" 扩展

// URL: dubbo://localhost:20880
// -> 使用 "default" 扩展// URL: dubbo://localhost:20880?robot.type=optimusPrime`
`#@SPI("default")
public interface Robot {
    @Adaptive({"robot.type", "robot"})
    void sayHello(URL url);
}

// URL: dubbo://localhost:20880?robot.type=optimusPrime
// -> 使用 "optimusPrime" 扩展

// URL: dubbo://localhost:20880?robot=bumblebee
// -> 使用 "bumblebee" 扩展

// URL: dubbo://localhost:20880
// -> 使用 "default" 扩展// -> 使用 "optimusPrime" 扩展`
`#@SPI("default")
public interface Robot {
    @Adaptive({"robot.type", "robot"})
    void sayHello(URL url);
}

// URL: dubbo://localhost:20880?robot.type=optimusPrime
// -> 使用 "optimusPrime" 扩展

// URL: dubbo://localhost:20880?robot=bumblebee
// -> 使用 "bumblebee" 扩展

// URL: dubbo://localhost:20880
// -> 使用 "default" 扩展`
`#@SPI("default")
public interface Robot {
    @Adaptive({"robot.type", "robot"})
    void sayHello(URL url);
}

// URL: dubbo://localhost:20880?robot.type=optimusPrime
// -> 使用 "optimusPrime" 扩展

// URL: dubbo://localhost:20880?robot=bumblebee
// -> 使用 "bumblebee" 扩展

// URL: dubbo://localhost:20880
// -> 使用 "default" 扩展// URL: dubbo://localhost:20880?robot=bumblebee`
`#@SPI("default")
public interface Robot {
    @Adaptive({"robot.type", "robot"})
    void sayHello(URL url);
}

// URL: dubbo://localhost:20880?robot.type=optimusPrime
// -> 使用 "optimusPrime" 扩展

// URL: dubbo://localhost:20880?robot=bumblebee
// -> 使用 "bumblebee" 扩展

// URL: dubbo://localhost:20880
// -> 使用 "default" 扩展// -> 使用 "bumblebee" 扩展`
`#@SPI("default")
public interface Robot {
    @Adaptive({"robot.type", "robot"})
    void sayHello(URL url);
}

// URL: dubbo://localhost:20880?robot.type=optimusPrime
// -> 使用 "optimusPrime" 扩展

// URL: dubbo://localhost:20880?robot=bumblebee
// -> 使用 "bumblebee" 扩展

// URL: dubbo://localhost:20880
// -> 使用 "default" 扩展`
`#@SPI("default")
public interface Robot {
    @Adaptive({"robot.type", "robot"})
    void sayHello(URL url);
}

// URL: dubbo://localhost:20880?robot.type=optimusPrime
// -> 使用 "optimusPrime" 扩展

// URL: dubbo://localhost:20880?robot=bumblebee
// -> 使用 "bumblebee" 扩展

// URL: dubbo://localhost:20880
// -> 使用 "default" 扩展// URL: dubbo://localhost:20880`
`#@SPI("default")
public interface Robot {
    @Adaptive({"robot.type", "robot"})
    void sayHello(URL url);
}

// URL: dubbo://localhost:20880?robot.type=optimusPrime
// -> 使用 "optimusPrime" 扩展

// URL: dubbo://localhost:20880?robot=bumblebee
// -> 使用 "bumblebee" 扩展

// URL: dubbo://localhost:20880
// -> 使用 "default" 扩展// -> 使用 "default" 扩展

4.6 常用 Dubbo 内置扩展点的自适应配置

表 4-1: Dubbo 常用扩展点的自适应配置
扩展点接口 @Adaptive 参数 URL 参数示例 说明
Protocol "protocol", "provider" dubbo://...?protocol=dubbo 根据协议选择实现
LoadBalance "loadbalance" dubbo://...?loadbalance=random 负载均衡策略
Cluster "cluster" dubbo://...?cluster=failover 集群容错策略
ProxyFactory "proxy" dubbo://...?proxy=javassist 代理工厂
Serialization "serialization" dubbo://...?serialization=hessian2 序列化方式
Transporter "server", "transporter" dubbo://...?server=netty4 网络传输层

五、激活扩展(Activate Extension)

5.1 @Activate 注解

@Activate 注解用于标识在特定条件下自动激活的扩展,常用于 Filter 等场景。

注解属性:

java 复制代码
#@Activate(group = {Constants.PROVIDER, Constants.CONSUMER}, 
          value = {Constants.DEFAULT_KEY},
          before = {"filter2"},
          after = {"filter1"},
          order = 100)
public class MyFilter implements Filter {
    // ...
}@Activate(group = {Constants.PROVIDER, Constants.CONSUMER}, `
`#@Activate(group = {Constants.PROVIDER, Constants.CONSUMER}, 
          value = {Constants.DEFAULT_KEY},
          before = {"filter2"},
          after = {"filter1"},
          order = 100)
public class MyFilter implements Filter {
    // ...
}          value = {Constants.DEFAULT_KEY},`
`#@Activate(group = {Constants.PROVIDER, Constants.CONSUMER}, 
          value = {Constants.DEFAULT_KEY},
          before = {"filter2"},
          after = {"filter1"},
          order = 100)
public class MyFilter implements Filter {
    // ...
}          before = {"filter2"},`
`#@Activate(group = {Constants.PROVIDER, Constants.CONSUMER}, 
          value = {Constants.DEFAULT_KEY},
          before = {"filter2"},
          after = {"filter1"},
          order = 100)
public class MyFilter implements Filter {
    // ...
}          after = {"filter1"},`
`#@Activate(group = {Constants.PROVIDER, Constants.CONSUMER}, 
          value = {Constants.DEFAULT_KEY},
          before = {"filter2"},
          after = {"filter1"},
          order = 100)
public class MyFilter implements Filter {
    // ...
}          order = 100)`
`#@Activate(group = {Constants.PROVIDER, Constants.CONSUMER}, 
          value = {Constants.DEFAULT_KEY},
          before = {"filter2"},
          after = {"filter1"},
          order = 100)
public class MyFilter implements Filter {
    // ...
}public class MyFilter implements Filter {`
`#@Activate(group = {Constants.PROVIDER, Constants.CONSUMER}, 
          value = {Constants.DEFAULT_KEY},
          before = {"filter2"},
          after = {"filter1"},
          order = 100)
public class MyFilter implements Filter {
    // ...
}    // ...`
`#@Activate(group = {Constants.PROVIDER, Constants.CONSUMER}, 
          value = {Constants.DEFAULT_KEY},
          before = {"filter2"},
          after = {"filter1"},
          order = 100)
public class MyFilter implements Filter {
    // ...
}}

属性说明:

  • group: 所属组(provider/consumer/all)
  • value: 激活条件(URL 参数匹配)
  • before/after: 排序规则
  • order: 排序优先级(数字越小优先级越高)

5.2 获取激活扩展的流程

java 复制代码
#/**
 * 根据条件获取激活的扩展列表
 * @param URL URL对象(包含条件参数)
 * @param value 指定的扩展名(可为null)
 * @param group 组过滤(provider/consumer)
 * @return 激活的扩展实例列表
 */
public List<T> getActivateExtension(URL url, String[] values, String group) {
    List<T> activateExtensions = new ArrayList<>();
    
    // 1. 获取所有扩展类的配置信息
    Map<String, Object> activateExtensionsMap = getActivateExtension(url, values, group);
    
    // 2. 排序(根据order、before、after)
    activateExtensions.addAll(activateExtensionsMap.keySet());
    activateExtensions.sort(new ActivateComparator());
    
    // 3. 创建扩展实例
    for (Object obj : activateExtensions) {
        String name = (String) obj;
        activateExtensions.add(getExtension(name));
    }
    
    return activateExtensions;
}/**`
`#/**
 * 根据条件获取激活的扩展列表
 * @param URL URL对象(包含条件参数)
 * @param value 指定的扩展名(可为null)
 * @param group 组过滤(provider/consumer)
 * @return 激活的扩展实例列表
 */
public List<T> getActivateExtension(URL url, String[] values, String group) {
    List<T> activateExtensions = new ArrayList<>();
    
    // 1. 获取所有扩展类的配置信息
    Map<String, Object> activateExtensionsMap = getActivateExtension(url, values, group);
    
    // 2. 排序(根据order、before、after)
    activateExtensions.addAll(activateExtensionsMap.keySet());
    activateExtensions.sort(new ActivateComparator());
    
    // 3. 创建扩展实例
    for (Object obj : activateExtensions) {
        String name = (String) obj;
        activateExtensions.add(getExtension(name));
    }
    
    return activateExtensions;
} * 根据条件获取激活的扩展列表`
`#/**
 * 根据条件获取激活的扩展列表
 * @param URL URL对象(包含条件参数)
 * @param value 指定的扩展名(可为null)
 * @param group 组过滤(provider/consumer)
 * @return 激活的扩展实例列表
 */
public List<T> getActivateExtension(URL url, String[] values, String group) {
    List<T> activateExtensions = new ArrayList<>();
    
    // 1. 获取所有扩展类的配置信息
    Map<String, Object> activateExtensionsMap = getActivateExtension(url, values, group);
    
    // 2. 排序(根据order、before、after)
    activateExtensions.addAll(activateExtensionsMap.keySet());
    activateExtensions.sort(new ActivateComparator());
    
    // 3. 创建扩展实例
    for (Object obj : activateExtensions) {
        String name = (String) obj;
        activateExtensions.add(getExtension(name));
    }
    
    return activateExtensions;
} * @param URL URL对象(包含条件参数)`
`#/**
 * 根据条件获取激活的扩展列表
 * @param URL URL对象(包含条件参数)
 * @param value 指定的扩展名(可为null)
 * @param group 组过滤(provider/consumer)
 * @return 激活的扩展实例列表
 */
public List<T> getActivateExtension(URL url, String[] values, String group) {
    List<T> activateExtensions = new ArrayList<>();
    
    // 1. 获取所有扩展类的配置信息
    Map<String, Object> activateExtensionsMap = getActivateExtension(url, values, group);
    
    // 2. 排序(根据order、before、after)
    activateExtensions.addAll(activateExtensionsMap.keySet());
    activateExtensions.sort(new ActivateComparator());
    
    // 3. 创建扩展实例
    for (Object obj : activateExtensions) {
        String name = (String) obj;
        activateExtensions.add(getExtension(name));
    }
    
    return activateExtensions;
} * @param value 指定的扩展名(可为null)`
`#/**
 * 根据条件获取激活的扩展列表
 * @param URL URL对象(包含条件参数)
 * @param value 指定的扩展名(可为null)
 * @param group 组过滤(provider/consumer)
 * @return 激活的扩展实例列表
 */
public List<T> getActivateExtension(URL url, String[] values, String group) {
    List<T> activateExtensions = new ArrayList<>();
    
    // 1. 获取所有扩展类的配置信息
    Map<String, Object> activateExtensionsMap = getActivateExtension(url, values, group);
    
    // 2. 排序(根据order、before、after)
    activateExtensions.addAll(activateExtensionsMap.keySet());
    activateExtensions.sort(new ActivateComparator());
    
    // 3. 创建扩展实例
    for (Object obj : activateExtensions) {
        String name = (String) obj;
        activateExtensions.add(getExtension(name));
    }
    
    return activateExtensions;
} * @param group 组过滤(provider/consumer)`
`#/**
 * 根据条件获取激活的扩展列表
 * @param URL URL对象(包含条件参数)
 * @param value 指定的扩展名(可为null)
 * @param group 组过滤(provider/consumer)
 * @return 激活的扩展实例列表
 */
public List<T> getActivateExtension(URL url, String[] values, String group) {
    List<T> activateExtensions = new ArrayList<>();
    
    // 1. 获取所有扩展类的配置信息
    Map<String, Object> activateExtensionsMap = getActivateExtension(url, values, group);
    
    // 2. 排序(根据order、before、after)
    activateExtensions.addAll(activateExtensionsMap.keySet());
    activateExtensions.sort(new ActivateComparator());
    
    // 3. 创建扩展实例
    for (Object obj : activateExtensions) {
        String name = (String) obj;
        activateExtensions.add(getExtension(name));
    }
    
    return activateExtensions;
} * @return 激活的扩展实例列表`
`#/**
 * 根据条件获取激活的扩展列表
 * @param URL URL对象(包含条件参数)
 * @param value 指定的扩展名(可为null)
 * @param group 组过滤(provider/consumer)
 * @return 激活的扩展实例列表
 */
public List<T> getActivateExtension(URL url, String[] values, String group) {
    List<T> activateExtensions = new ArrayList<>();
    
    // 1. 获取所有扩展类的配置信息
    Map<String, Object> activateExtensionsMap = getActivateExtension(url, values, group);
    
    // 2. 排序(根据order、before、after)
    activateExtensions.addAll(activateExtensionsMap.keySet());
    activateExtensions.sort(new ActivateComparator());
    
    // 3. 创建扩展实例
    for (Object obj : activateExtensions) {
        String name = (String) obj;
        activateExtensions.add(getExtension(name));
    }
    
    return activateExtensions;
} */`
`#/**
 * 根据条件获取激活的扩展列表
 * @param URL URL对象(包含条件参数)
 * @param value 指定的扩展名(可为null)
 * @param group 组过滤(provider/consumer)
 * @return 激活的扩展实例列表
 */
public List<T> getActivateExtension(URL url, String[] values, String group) {
    List<T> activateExtensions = new ArrayList<>();
    
    // 1. 获取所有扩展类的配置信息
    Map<String, Object> activateExtensionsMap = getActivateExtension(url, values, group);
    
    // 2. 排序(根据order、before、after)
    activateExtensions.addAll(activateExtensionsMap.keySet());
    activateExtensions.sort(new ActivateComparator());
    
    // 3. 创建扩展实例
    for (Object obj : activateExtensions) {
        String name = (String) obj;
        activateExtensions.add(getExtension(name));
    }
    
    return activateExtensions;
}public List<T> getActivateExtension(URL url, String[] values, String group) {`
`#/**
 * 根据条件获取激活的扩展列表
 * @param URL URL对象(包含条件参数)
 * @param value 指定的扩展名(可为null)
 * @param group 组过滤(provider/consumer)
 * @return 激活的扩展实例列表
 */
public List<T> getActivateExtension(URL url, String[] values, String group) {
    List<T> activateExtensions = new ArrayList<>();
    
    // 1. 获取所有扩展类的配置信息
    Map<String, Object> activateExtensionsMap = getActivateExtension(url, values, group);
    
    // 2. 排序(根据order、before、after)
    activateExtensions.addAll(activateExtensionsMap.keySet());
    activateExtensions.sort(new ActivateComparator());
    
    // 3. 创建扩展实例
    for (Object obj : activateExtensions) {
        String name = (String) obj;
        activateExtensions.add(getExtension(name));
    }
    
    return activateExtensions;
}    List<T> activateExtensions = new ArrayList<>();`
`#/**
 * 根据条件获取激活的扩展列表
 * @param URL URL对象(包含条件参数)
 * @param value 指定的扩展名(可为null)
 * @param group 组过滤(provider/consumer)
 * @return 激活的扩展实例列表
 */
public List<T> getActivateExtension(URL url, String[] values, String group) {
    List<T> activateExtensions = new ArrayList<>();
    
    // 1. 获取所有扩展类的配置信息
    Map<String, Object> activateExtensionsMap = getActivateExtension(url, values, group);
    
    // 2. 排序(根据order、before、after)
    activateExtensions.addAll(activateExtensionsMap.keySet());
    activateExtensions.sort(new ActivateComparator());
    
    // 3. 创建扩展实例
    for (Object obj : activateExtensions) {
        String name = (String) obj;
        activateExtensions.add(getExtension(name));
    }
    
    return activateExtensions;
}    `
`#/**
 * 根据条件获取激活的扩展列表
 * @param URL URL对象(包含条件参数)
 * @param value 指定的扩展名(可为null)
 * @param group 组过滤(provider/consumer)
 * @return 激活的扩展实例列表
 */
public List<T> getActivateExtension(URL url, String[] values, String group) {
    List<T> activateExtensions = new ArrayList<>();
    
    // 1. 获取所有扩展类的配置信息
    Map<String, Object> activateExtensionsMap = getActivateExtension(url, values, group);
    
    // 2. 排序(根据order、before、after)
    activateExtensions.addAll(activateExtensionsMap.keySet());
    activateExtensions.sort(new ActivateComparator());
    
    // 3. 创建扩展实例
    for (Object obj : activateExtensions) {
        String name = (String) obj;
        activateExtensions.add(getExtension(name));
    }
    
    return activateExtensions;
}    // 1. 获取所有扩展类的配置信息`
`#/**
 * 根据条件获取激活的扩展列表
 * @param URL URL对象(包含条件参数)
 * @param value 指定的扩展名(可为null)
 * @param group 组过滤(provider/consumer)
 * @return 激活的扩展实例列表
 */
public List<T> getActivateExtension(URL url, String[] values, String group) {
    List<T> activateExtensions = new ArrayList<>();
    
    // 1. 获取所有扩展类的配置信息
    Map<String, Object> activateExtensionsMap = getActivateExtension(url, values, group);
    
    // 2. 排序(根据order、before、after)
    activateExtensions.addAll(activateExtensionsMap.keySet());
    activateExtensions.sort(new ActivateComparator());
    
    // 3. 创建扩展实例
    for (Object obj : activateExtensions) {
        String name = (String) obj;
        activateExtensions.add(getExtension(name));
    }
    
    return activateExtensions;
}    Map<String, Object> activateExtensionsMap = getActivateExtension(url, values, group);`
`#/**
 * 根据条件获取激活的扩展列表
 * @param URL URL对象(包含条件参数)
 * @param value 指定的扩展名(可为null)
 * @param group 组过滤(provider/consumer)
 * @return 激活的扩展实例列表
 */
public List<T> getActivateExtension(URL url, String[] values, String group) {
    List<T> activateExtensions = new ArrayList<>();
    
    // 1. 获取所有扩展类的配置信息
    Map<String, Object> activateExtensionsMap = getActivateExtension(url, values, group);
    
    // 2. 排序(根据order、before、after)
    activateExtensions.addAll(activateExtensionsMap.keySet());
    activateExtensions.sort(new ActivateComparator());
    
    // 3. 创建扩展实例
    for (Object obj : activateExtensions) {
        String name = (String) obj;
        activateExtensions.add(getExtension(name));
    }
    
    return activateExtensions;
}    `
`#/**
 * 根据条件获取激活的扩展列表
 * @param URL URL对象(包含条件参数)
 * @param value 指定的扩展名(可为null)
 * @param group 组过滤(provider/consumer)
 * @return 激活的扩展实例列表
 */
public List<T> getActivateExtension(URL url, String[] values, String group) {
    List<T> activateExtensions = new ArrayList<>();
    
    // 1. 获取所有扩展类的配置信息
    Map<String, Object> activateExtensionsMap = getActivateExtension(url, values, group);
    
    // 2. 排序(根据order、before、after)
    activateExtensions.addAll(activateExtensionsMap.keySet());
    activateExtensions.sort(new ActivateComparator());
    
    // 3. 创建扩展实例
    for (Object obj : activateExtensions) {
        String name = (String) obj;
        activateExtensions.add(getExtension(name));
    }
    
    return activateExtensions;
}    // 2. 排序(根据order、before、after)`
`#/**
 * 根据条件获取激活的扩展列表
 * @param URL URL对象(包含条件参数)
 * @param value 指定的扩展名(可为null)
 * @param group 组过滤(provider/consumer)
 * @return 激活的扩展实例列表
 */
public List<T> getActivateExtension(URL url, String[] values, String group) {
    List<T> activateExtensions = new ArrayList<>();
    
    // 1. 获取所有扩展类的配置信息
    Map<String, Object> activateExtensionsMap = getActivateExtension(url, values, group);
    
    // 2. 排序(根据order、before、after)
    activateExtensions.addAll(activateExtensionsMap.keySet());
    activateExtensions.sort(new ActivateComparator());
    
    // 3. 创建扩展实例
    for (Object obj : activateExtensions) {
        String name = (String) obj;
        activateExtensions.add(getExtension(name));
    }
    
    return activateExtensions;
}    activateExtensions.addAll(activateExtensionsMap.keySet());`
`#/**
 * 根据条件获取激活的扩展列表
 * @param URL URL对象(包含条件参数)
 * @param value 指定的扩展名(可为null)
 * @param group 组过滤(provider/consumer)
 * @return 激活的扩展实例列表
 */
public List<T> getActivateExtension(URL url, String[] values, String group) {
    List<T> activateExtensions = new ArrayList<>();
    
    // 1. 获取所有扩展类的配置信息
    Map<String, Object> activateExtensionsMap = getActivateExtension(url, values, group);
    
    // 2. 排序(根据order、before、after)
    activateExtensions.addAll(activateExtensionsMap.keySet());
    activateExtensions.sort(new ActivateComparator());
    
    // 3. 创建扩展实例
    for (Object obj : activateExtensions) {
        String name = (String) obj;
        activateExtensions.add(getExtension(name));
    }
    
    return activateExtensions;
}    activateExtensions.sort(new ActivateComparator());`
`#/**
 * 根据条件获取激活的扩展列表
 * @param URL URL对象(包含条件参数)
 * @param value 指定的扩展名(可为null)
 * @param group 组过滤(provider/consumer)
 * @return 激活的扩展实例列表
 */
public List<T> getActivateExtension(URL url, String[] values, String group) {
    List<T> activateExtensions = new ArrayList<>();
    
    // 1. 获取所有扩展类的配置信息
    Map<String, Object> activateExtensionsMap = getActivateExtension(url, values, group);
    
    // 2. 排序(根据order、before、after)
    activateExtensions.addAll(activateExtensionsMap.keySet());
    activateExtensions.sort(new ActivateComparator());
    
    // 3. 创建扩展实例
    for (Object obj : activateExtensions) {
        String name = (String) obj;
        activateExtensions.add(getExtension(name));
    }
    
    return activateExtensions;
}    `
`#/**
 * 根据条件获取激活的扩展列表
 * @param URL URL对象(包含条件参数)
 * @param value 指定的扩展名(可为null)
 * @param group 组过滤(provider/consumer)
 * @return 激活的扩展实例列表
 */
public List<T> getActivateExtension(URL url, String[] values, String group) {
    List<T> activateExtensions = new ArrayList<>();
    
    // 1. 获取所有扩展类的配置信息
    Map<String, Object> activateExtensionsMap = getActivateExtension(url, values, group);
    
    // 2. 排序(根据order、before、after)
    activateExtensions.addAll(activateExtensionsMap.keySet());
    activateExtensions.sort(new ActivateComparator());
    
    // 3. 创建扩展实例
    for (Object obj : activateExtensions) {
        String name = (String) obj;
        activateExtensions.add(getExtension(name));
    }
    
    return activateExtensions;
}    // 3. 创建扩展实例`
`#/**
 * 根据条件获取激活的扩展列表
 * @param URL URL对象(包含条件参数)
 * @param value 指定的扩展名(可为null)
 * @param group 组过滤(provider/consumer)
 * @return 激活的扩展实例列表
 */
public List<T> getActivateExtension(URL url, String[] values, String group) {
    List<T> activateExtensions = new ArrayList<>();
    
    // 1. 获取所有扩展类的配置信息
    Map<String, Object> activateExtensionsMap = getActivateExtension(url, values, group);
    
    // 2. 排序(根据order、before、after)
    activateExtensions.addAll(activateExtensionsMap.keySet());
    activateExtensions.sort(new ActivateComparator());
    
    // 3. 创建扩展实例
    for (Object obj : activateExtensions) {
        String name = (String) obj;
        activateExtensions.add(getExtension(name));
    }
    
    return activateExtensions;
}    for (Object obj : activateExtensions) {`
`#/**
 * 根据条件获取激活的扩展列表
 * @param URL URL对象(包含条件参数)
 * @param value 指定的扩展名(可为null)
 * @param group 组过滤(provider/consumer)
 * @return 激活的扩展实例列表
 */
public List<T> getActivateExtension(URL url, String[] values, String group) {
    List<T> activateExtensions = new ArrayList<>();
    
    // 1. 获取所有扩展类的配置信息
    Map<String, Object> activateExtensionsMap = getActivateExtension(url, values, group);
    
    // 2. 排序(根据order、before、after)
    activateExtensions.addAll(activateExtensionsMap.keySet());
    activateExtensions.sort(new ActivateComparator());
    
    // 3. 创建扩展实例
    for (Object obj : activateExtensions) {
        String name = (String) obj;
        activateExtensions.add(getExtension(name));
    }
    
    return activateExtensions;
}        String name = (String) obj;`
`#/**
 * 根据条件获取激活的扩展列表
 * @param URL URL对象(包含条件参数)
 * @param value 指定的扩展名(可为null)
 * @param group 组过滤(provider/consumer)
 * @return 激活的扩展实例列表
 */
public List<T> getActivateExtension(URL url, String[] values, String group) {
    List<T> activateExtensions = new ArrayList<>();
    
    // 1. 获取所有扩展类的配置信息
    Map<String, Object> activateExtensionsMap = getActivateExtension(url, values, group);
    
    // 2. 排序(根据order、before、after)
    activateExtensions.addAll(activateExtensionsMap.keySet());
    activateExtensions.sort(new ActivateComparator());
    
    // 3. 创建扩展实例
    for (Object obj : activateExtensions) {
        String name = (String) obj;
        activateExtensions.add(getExtension(name));
    }
    
    return activateExtensions;
}        activateExtensions.add(getExtension(name));`
`#/**
 * 根据条件获取激活的扩展列表
 * @param URL URL对象(包含条件参数)
 * @param value 指定的扩展名(可为null)
 * @param group 组过滤(provider/consumer)
 * @return 激活的扩展实例列表
 */
public List<T> getActivateExtension(URL url, String[] values, String group) {
    List<T> activateExtensions = new ArrayList<>();
    
    // 1. 获取所有扩展类的配置信息
    Map<String, Object> activateExtensionsMap = getActivateExtension(url, values, group);
    
    // 2. 排序(根据order、before、after)
    activateExtensions.addAll(activateExtensionsMap.keySet());
    activateExtensions.sort(new ActivateComparator());
    
    // 3. 创建扩展实例
    for (Object obj : activateExtensions) {
        String name = (String) obj;
        activateExtensions.add(getExtension(name));
    }
    
    return activateExtensions;
}    }`
`#/**
 * 根据条件获取激活的扩展列表
 * @param URL URL对象(包含条件参数)
 * @param value 指定的扩展名(可为null)
 * @param group 组过滤(provider/consumer)
 * @return 激活的扩展实例列表
 */
public List<T> getActivateExtension(URL url, String[] values, String group) {
    List<T> activateExtensions = new ArrayList<>();
    
    // 1. 获取所有扩展类的配置信息
    Map<String, Object> activateExtensionsMap = getActivateExtension(url, values, group);
    
    // 2. 排序(根据order、before、after)
    activateExtensions.addAll(activateExtensionsMap.keySet());
    activateExtensions.sort(new ActivateComparator());
    
    // 3. 创建扩展实例
    for (Object obj : activateExtensions) {
        String name = (String) obj;
        activateExtensions.add(getExtension(name));
    }
    
    return activateExtensions;
}    `
`#/**
 * 根据条件获取激活的扩展列表
 * @param URL URL对象(包含条件参数)
 * @param value 指定的扩展名(可为null)
 * @param group 组过滤(provider/consumer)
 * @return 激活的扩展实例列表
 */
public List<T> getActivateExtension(URL url, String[] values, String group) {
    List<T> activateExtensions = new ArrayList<>();
    
    // 1. 获取所有扩展类的配置信息
    Map<String, Object> activateExtensionsMap = getActivateExtension(url, values, group);
    
    // 2. 排序(根据order、before、after)
    activateExtensions.addAll(activateExtensionsMap.keySet());
    activateExtensions.sort(new ActivateComparator());
    
    // 3. 创建扩展实例
    for (Object obj : activateExtensions) {
        String name = (String) obj;
        activateExtensions.add(getExtension(name));
    }
    
    return activateExtensions;
}    return activateExtensions;`
`#/**
 * 根据条件获取激活的扩展列表
 * @param URL URL对象(包含条件参数)
 * @param value 指定的扩展名(可为null)
 * @param group 组过滤(provider/consumer)
 * @return 激活的扩展实例列表
 */
public List<T> getActivateExtension(URL url, String[] values, String group) {
    List<T> activateExtensions = new ArrayList<>();
    
    // 1. 获取所有扩展类的配置信息
    Map<String, Object> activateExtensionsMap = getActivateExtension(url, values, group);
    
    // 2. 排序(根据order、before、after)
    activateExtensions.addAll(activateExtensionsMap.keySet());
    activateExtensions.sort(new ActivateComparator());
    
    // 3. 创建扩展实例
    for (Object obj : activateExtensions) {
        String name = (String) obj;
        activateExtensions.add(getExtension(name));
    }
    
    return activateExtensions;
}}

5.3 Filter 链式调用示例

复制代码
sequenceDiagram
    participant Client
    participant Filter1 as Filter1<br/>(order=10)
    participant Filter2 as Filter2<br/>(order=20)
    participant Filter3 as Filter3<br/>(order=30)
    participant Invoker
    
    Client->>Filter1: invoke(invocation)
    Filter1->>Filter1: 前置逻辑
    Filter1->>Filter2: invoke(invocation)
    Filter2->>Filter2: 前置逻辑
    Filter2->>Filter3: invoke(invocation)
    Filter3->>Filter3: 前置逻辑
    Filter3->>Invoker: invoke(invocation)
    Invoker-->>Filter3: 返回结果
    Filter3->>Filter3: 后置逻辑
    Filter3-->>Filter2: 返回结果
    Filter2->>Filter2: 后置逻辑
    Filter2-->>Filter1: 返回结果
    Filter1->>Filter1: 后置逻辑
    Filter1-->>Client: 返回结果

六、ExtensionLoader 加载机制

6.1 配置文件加载优先级

Dubbo SPI 会从以下三个路径按顺序加载配置文件:

java 复制代码
#// 加载顺序(优先级从高到低)
private static final String[] LOAD_DIRECTORIES = {
    "META-INF/dubbo/internal/", // 内部扩展(框架自带)
    "META-INF/dubbo/",          // 用户扩展
    "META-INF/services/"         // Java SPI 兼容
};// 加载顺序(优先级从高到低)`
`#// 加载顺序(优先级从高到低)
private static final String[] LOAD_DIRECTORIES = {
    "META-INF/dubbo/internal/", // 内部扩展(框架自带)
    "META-INF/dubbo/",          // 用户扩展
    "META-INF/services/"         // Java SPI 兼容
};private static final String[] LOAD_DIRECTORIES = {`
`#// 加载顺序(优先级从高到低)
private static final String[] LOAD_DIRECTORIES = {
    "META-INF/dubbo/internal/", // 内部扩展(框架自带)
    "META-INF/dubbo/",          // 用户扩展
    "META-INF/services/"         // Java SPI 兼容
};    "META-INF/dubbo/internal/", // 内部扩展(框架自带)`
`#// 加载顺序(优先级从高到低)
private static final String[] LOAD_DIRECTORIES = {
    "META-INF/dubbo/internal/", // 内部扩展(框架自带)
    "META-INF/dubbo/",          // 用户扩展
    "META-INF/services/"         // Java SPI 兼容
};    "META-INF/dubbo/",          // 用户扩展`
`#// 加载顺序(优先级从高到低)
private static final String[] LOAD_DIRECTORIES = {
    "META-INF/dubbo/internal/", // 内部扩展(框架自带)
    "META-INF/dubbo/",          // 用户扩展
    "META-INF/services/"         // Java SPI 兼容
};    "META-INF/services/"         // Java SPI 兼容`
`#// 加载顺序(优先级从高到低)
private static final String[] LOAD_DIRECTORIES = {
    "META-INF/dubbo/internal/", // 内部扩展(框架自带)
    "META-INF/dubbo/",          // 用户扩展
    "META-INF/services/"         // Java SPI 兼容
};};
表 6-1: 配置文件路径说明
路径 用途 优先级 示例
META-INF/dubbo/internal/ Dubbo 框架内部扩展 最高 Protocol、LoadBalance 等核心扩展
META-INF/dubbo/ 用户自定义扩展 中间 业务系统自定义的扩展实现
META-INF/services/ Java SPI 兼容 最低 第三方库的兼容性配置

6.2 扩展类加载流程

java 复制代码
#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}/**`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
} * 获取所有扩展类的Class映射`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
} */`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}private Map<String, Class<?>> getExtensionClasses() {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    // 1. 双重检查锁`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    Map<String, Class<?>> classes = cachedClasses;`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    if (classes == null) {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}        synchronized (cachedClasses) {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            classes = cachedClasses;`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            if (classes == null) {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                // 2. 加载扩展类`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                classes = loadExtensionClasses();`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                // 3. 放入缓存`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                cachedClasses = classes;`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            }`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}        }`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    }`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    return classes;`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}}`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}/**`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
} * 加载所有扩展类`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
} */`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}private Map<String, Class<?>> loadExtensionClasses() {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    cacheDefaultExtensionName(); // 缓存默认扩展名`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    `
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    Map<String, Class<?>> extensionClasses = new HashMap<>();`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    `
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    // 遍历三个目录`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    for (LoadingStrategy strategy : strategies) {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}        loadDirectory(extensionClasses, strategy.directory(), type.getName(), strategy.preferExtensionClassLoader(), `
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            strategy.overridden(), strategy.excludedPackages());`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    }`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    `
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    return extensionClasses;`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}}`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}/**`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
} * 从指定目录加载配置文件`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
} */`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}private void loadDirectory(Map<String, Class<?>> extensionClasses, String dir, `
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                          String type, boolean extensionLoaderClassLoaderFirst, `
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                          boolean overridden, String... excludedPackages) {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    // 1. 构建文件名: META-INF/dubbo/com.example.Robot`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    String fileName = dir + type;`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    try {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}        Enumeration<java.net.URL> urls;`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}        // 2. 获取类加载器`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}        ClassLoader classLoader = findClassLoader();`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}        `
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}        // 3. 查找资源文件`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}        if (extensionLoaderClassLoaderFirst) {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            ClassLoader extensionLoaderClassLoader = ExtensionLoader.class.getClassLoader();`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            if (ClassLoader.getSystemClassLoader() != extensionLoaderClassLoader) {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                urls = extensionLoaderClassLoader.getResources(fileName);`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            } else {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                urls = classLoader.getResources(fileName);`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            }`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}        } else {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            urls = classLoader.getResources(fileName);`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}        }`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}        `
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}        // 4. 解析配置文件`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}        if (urls != null) {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            while (urls.hasMoreElements()) {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                java.net.URL resourceURL = urls.nextElement();`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                loadResource(extensionClasses, classLoader, resourceURL, overridden, excludedPackages);`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            }`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}        }`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    } catch (Throwable t) {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}        logger.error("Exception occurred when loading extension class (interface: " +`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            type + ", description file: " + fileName + ").", t);`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    }`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}}`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}/**`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
} * 解析单个配置文件`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
} */`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}private void loadResource(Map<String, Class<?>> extensionClasses, ClassLoader classLoader,`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                         java.net.URL resourceURL, boolean overridden, String[] excludedPackages) {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    try (BufferedReader reader = new BufferedReader(new InputStreamReader(resourceURL.openStream(), StandardCharsets.UTF_8))) {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}        String line;`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}        while ((line = reader.readLine()) != null) {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            // 1. 跳过注释和空行`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            final int ci = line.indexOf('#');`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            if (ci >= 0) {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                line = line.substring(0, ci);`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            }`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            line = line.trim();`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            if (line.length() > 0) {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                try {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                    String name = null;`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                    // 2. 解析 "name=class" 格式`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                    int i = line.indexOf('=');`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                    if (i > 0) {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                        name = line.substring(0, i).trim();`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                        line = line.substring(i + 1).trim();`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                    }`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                    if (line.length() > 0) {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                        // 3. 加载Class`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                    }`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                } catch (Throwable t) {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                    logger.error("Failed to load extension class (interface: " + type + `
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                }`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            }`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}        }`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    } catch (Throwable t) {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}        logger.error("Exception when loading extension class (interface: " + type + `
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            ", class file: " + resourceURL + ") in " + resourceURL, t);`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    }`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}}`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}/**`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
} * 加载单个Class并进行分类`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
} */`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    if (!type.isAssignableFrom(clazz)) {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}        throw new IllegalStateException("Error occurred when loading extension class (interface: " +`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    }`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    `
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    // 1. 检查是否是自适应扩展类`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    if (clazz.isAnnotationPresent(Adaptive.class)) {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}        cachedAdaptiveClass = clazz;`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    } `
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    // 2. 检查是否是Wrapper类`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    else if (isWrapperClass(clazz)) {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}        if (cachedWrapperClasses == null) {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            cachedWrapperClasses = new ConcurrentHashSet<>();`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}        }`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}        cachedWrapperClasses.add(clazz);`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    } `
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    // 3. 普通扩展类`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    else {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}        if (StringUtils.isEmpty(name)) {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            // 如果没有指定name,使用类名的小写形式`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            name = findAnnotationName(clazz);`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            if (name.length() == 0) {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            }`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}        }`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}        `
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}        String[] names = NAME_SEPARATOR.split(name);`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}        if (ArrayUtils.isNotEmpty(names)) {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            // 4. 检查@Activate注解`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            if (cachedActivates == null) {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                cachedActivates = new ConcurrentHashMap<>();`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            }`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            Activate activate = clazz.getAnnotation(Activate.class);`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            if (activate != null) {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                cachedActivates.put(names[0], activate);`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            }`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            `
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            // 5. 放入缓存`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            for (String n : names) {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                if (!cachedNames.containsKey(clazz)) {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                    cachedNames.put(clazz, n);`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                }`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                Class<?> c = extensionClasses.get(n);`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                if (c == null || overridden) {`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                    extensionClasses.put(n, clazz);`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}                }`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}            }`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}        }`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}    }`
`#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }
            line = line.trim();
            if (line.length() > 0) {
                try {
                    String name = null;
                    // 2. 解析 "name=class" 格式
                    int i = line.indexOf('=');
                    if (i > 0) {
                        name = line.substring(0, i).trim();
                        line = line.substring(i + 1).trim();
                    }
                    if (line.length() > 0) {
                        // 3. 加载Class
                        loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name, overridden);
                    }
                } catch (Throwable t) {
                    logger.error("Failed to load extension class (interface: " + type + 
                        ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Exception when loading extension class (interface: " + type + 
            ", class file: " + resourceURL + ") in " + resourceURL, t);
    }
}

/**
 * 加载单个Class并进行分类
 */
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL,
                      Class<?> clazz, String name, boolean overridden) throws NoSuchMethodException {
    if (!type.isAssignableFrom(clazz)) {
        throw new IllegalStateException("Error occurred when loading extension class (interface: " +
            type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface.");
    }
    
    // 1. 检查是否是自适应扩展类
    if (clazz.isAnnotationPresent(Adaptive.class)) {
        cachedAdaptiveClass = clazz;
    } 
    // 2. 检查是否是Wrapper类
    else if (isWrapperClass(clazz)) {
        if (cachedWrapperClasses == null) {
            cachedWrapperClasses = new ConcurrentHashSet<>();
        }
        cachedWrapperClasses.add(clazz);
    } 
    // 3. 普通扩展类
    else {
        if (StringUtils.isEmpty(name)) {
            // 如果没有指定name,使用类名的小写形式
            name = findAnnotationName(clazz);
            if (name.length() == 0) {
                throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL);
            }
        }
        
        String[] names = NAME_SEPARATOR.split(name);
        if (ArrayUtils.isNotEmpty(names)) {
            // 4. 检查@Activate注解
            if (cachedActivates == null) {
                cachedActivates = new ConcurrentHashMap<>();
            }
            Activate activate = clazz.getAnnotation(Activate.class);
            if (activate != null) {
                cachedActivates.put(names[0], activate);
            }
            
            // 5. 放入缓存
            for (String n : names) {
                if (!cachedNames.containsKey(clazz)) {
                    cachedNames.put(clazz, n);
                }
                Class<?> c = extensionClasses.get(n);
                if (c == null || overridden) {
                    extensionClasses.put(n, clazz);
                }
            }
        }
    }
}}

6.3 类加载流程图

复制代码
flowchart TD
    A[getExtensionClasses] --> B{缓存是否存在?}
    B -->|是| C[返回缓存]
    B -->|否| D[loadExtensionClasses]
    
    D --> E[cacheDefaultExtensionName<br/>缓存默认扩展名]
    E --> F[遍历三个目录]
    
    F --> G[META-INF/dubbo/internal/]
    F --> H[META-INF/dubbo/]
    F --> I[META-INF/services/]
    
    G --> J[loadDirectory]
    H --> J
    I --> J
    
    J --> K[查找资源文件]
    K --> L[loadResource<br/>解析配置文件]
    
    L --> M[逐行解析]
    M --> N{line格式?}
    
    N -->|key=value| O[name=key, clazz=value]
    N -->|仅value| P[name=自动推断, clazz=value]
    
    O --> Q[loadClass]
    P --> Q
    
    Q --> R{clazz类型判断}
    
    R -->|@Adaptive注解| S[cachedAdaptiveClass]
    R -->|Wrapper类| T[cachedWrapperClasses]
    R -->|普通类| U[extensionClasses.put]
    
    T --> V[继续下一行]
    S --> V
    U --> V
    V --> M
    
    style A fill:#e1f5ff
    style D fill:#fff4e1
    style J fill:#ffe1f5
    style Q fill:#f0ffe1
    style R fill:#e1ffff

七、实战案例

7.1 自定义 Dubbo 扩展

让我们通过一个完整的示例来演示如何自定义 Dubbo 扩展。

步骤1: 定义扩展点接口
java 复制代码
#package com.example.dubbo.spi;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

/**
 * 机器人扩展点接口
 * 
 * @SPI 注解标记这是一个扩展点
 * "default" 指定默认扩展实现名称
 */
@SPI("default")
public interface Robot {
    /**
     * 打招呼方法
     * @Adaptive 注解标记这是一个自适应方法
     * robot.type: 从URL的robot.type参数获取扩展名
     */
    @Adaptive({"robot.type"})
    void sayHello(URL url);
    
    /**
     * 攻击方法
     * adaptiveKey: 从URL的attack.type参数获取扩展名
     */
    @Adaptive({"attack.type", "attack"})
    void attack(URL url);
}package com.example.dubbo.spi;`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

/**
 * 机器人扩展点接口
 * 
 * @SPI 注解标记这是一个扩展点
 * "default" 指定默认扩展实现名称
 */
@SPI("default")
public interface Robot {
    /**
     * 打招呼方法
     * @Adaptive 注解标记这是一个自适应方法
     * robot.type: 从URL的robot.type参数获取扩展名
     */
    @Adaptive({"robot.type"})
    void sayHello(URL url);
    
    /**
     * 攻击方法
     * adaptiveKey: 从URL的attack.type参数获取扩展名
     */
    @Adaptive({"attack.type", "attack"})
    void attack(URL url);
}`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

/**
 * 机器人扩展点接口
 * 
 * @SPI 注解标记这是一个扩展点
 * "default" 指定默认扩展实现名称
 */
@SPI("default")
public interface Robot {
    /**
     * 打招呼方法
     * @Adaptive 注解标记这是一个自适应方法
     * robot.type: 从URL的robot.type参数获取扩展名
     */
    @Adaptive({"robot.type"})
    void sayHello(URL url);
    
    /**
     * 攻击方法
     * adaptiveKey: 从URL的attack.type参数获取扩展名
     */
    @Adaptive({"attack.type", "attack"})
    void attack(URL url);
}import org.apache.dubbo.common.URL;`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

/**
 * 机器人扩展点接口
 * 
 * @SPI 注解标记这是一个扩展点
 * "default" 指定默认扩展实现名称
 */
@SPI("default")
public interface Robot {
    /**
     * 打招呼方法
     * @Adaptive 注解标记这是一个自适应方法
     * robot.type: 从URL的robot.type参数获取扩展名
     */
    @Adaptive({"robot.type"})
    void sayHello(URL url);
    
    /**
     * 攻击方法
     * adaptiveKey: 从URL的attack.type参数获取扩展名
     */
    @Adaptive({"attack.type", "attack"})
    void attack(URL url);
}import org.apache.dubbo.common.extension.Adaptive;`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

/**
 * 机器人扩展点接口
 * 
 * @SPI 注解标记这是一个扩展点
 * "default" 指定默认扩展实现名称
 */
@SPI("default")
public interface Robot {
    /**
     * 打招呼方法
     * @Adaptive 注解标记这是一个自适应方法
     * robot.type: 从URL的robot.type参数获取扩展名
     */
    @Adaptive({"robot.type"})
    void sayHello(URL url);
    
    /**
     * 攻击方法
     * adaptiveKey: 从URL的attack.type参数获取扩展名
     */
    @Adaptive({"attack.type", "attack"})
    void attack(URL url);
}import org.apache.dubbo.common.extension.SPI;`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

/**
 * 机器人扩展点接口
 * 
 * @SPI 注解标记这是一个扩展点
 * "default" 指定默认扩展实现名称
 */
@SPI("default")
public interface Robot {
    /**
     * 打招呼方法
     * @Adaptive 注解标记这是一个自适应方法
     * robot.type: 从URL的robot.type参数获取扩展名
     */
    @Adaptive({"robot.type"})
    void sayHello(URL url);
    
    /**
     * 攻击方法
     * adaptiveKey: 从URL的attack.type参数获取扩展名
     */
    @Adaptive({"attack.type", "attack"})
    void attack(URL url);
}`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

/**
 * 机器人扩展点接口
 * 
 * @SPI 注解标记这是一个扩展点
 * "default" 指定默认扩展实现名称
 */
@SPI("default")
public interface Robot {
    /**
     * 打招呼方法
     * @Adaptive 注解标记这是一个自适应方法
     * robot.type: 从URL的robot.type参数获取扩展名
     */
    @Adaptive({"robot.type"})
    void sayHello(URL url);
    
    /**
     * 攻击方法
     * adaptiveKey: 从URL的attack.type参数获取扩展名
     */
    @Adaptive({"attack.type", "attack"})
    void attack(URL url);
}/**`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

/**
 * 机器人扩展点接口
 * 
 * @SPI 注解标记这是一个扩展点
 * "default" 指定默认扩展实现名称
 */
@SPI("default")
public interface Robot {
    /**
     * 打招呼方法
     * @Adaptive 注解标记这是一个自适应方法
     * robot.type: 从URL的robot.type参数获取扩展名
     */
    @Adaptive({"robot.type"})
    void sayHello(URL url);
    
    /**
     * 攻击方法
     * adaptiveKey: 从URL的attack.type参数获取扩展名
     */
    @Adaptive({"attack.type", "attack"})
    void attack(URL url);
} * 机器人扩展点接口`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

/**
 * 机器人扩展点接口
 * 
 * @SPI 注解标记这是一个扩展点
 * "default" 指定默认扩展实现名称
 */
@SPI("default")
public interface Robot {
    /**
     * 打招呼方法
     * @Adaptive 注解标记这是一个自适应方法
     * robot.type: 从URL的robot.type参数获取扩展名
     */
    @Adaptive({"robot.type"})
    void sayHello(URL url);
    
    /**
     * 攻击方法
     * adaptiveKey: 从URL的attack.type参数获取扩展名
     */
    @Adaptive({"attack.type", "attack"})
    void attack(URL url);
} * `
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

/**
 * 机器人扩展点接口
 * 
 * @SPI 注解标记这是一个扩展点
 * "default" 指定默认扩展实现名称
 */
@SPI("default")
public interface Robot {
    /**
     * 打招呼方法
     * @Adaptive 注解标记这是一个自适应方法
     * robot.type: 从URL的robot.type参数获取扩展名
     */
    @Adaptive({"robot.type"})
    void sayHello(URL url);
    
    /**
     * 攻击方法
     * adaptiveKey: 从URL的attack.type参数获取扩展名
     */
    @Adaptive({"attack.type", "attack"})
    void attack(URL url);
} * @SPI 注解标记这是一个扩展点`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

/**
 * 机器人扩展点接口
 * 
 * @SPI 注解标记这是一个扩展点
 * "default" 指定默认扩展实现名称
 */
@SPI("default")
public interface Robot {
    /**
     * 打招呼方法
     * @Adaptive 注解标记这是一个自适应方法
     * robot.type: 从URL的robot.type参数获取扩展名
     */
    @Adaptive({"robot.type"})
    void sayHello(URL url);
    
    /**
     * 攻击方法
     * adaptiveKey: 从URL的attack.type参数获取扩展名
     */
    @Adaptive({"attack.type", "attack"})
    void attack(URL url);
} * "default" 指定默认扩展实现名称`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

/**
 * 机器人扩展点接口
 * 
 * @SPI 注解标记这是一个扩展点
 * "default" 指定默认扩展实现名称
 */
@SPI("default")
public interface Robot {
    /**
     * 打招呼方法
     * @Adaptive 注解标记这是一个自适应方法
     * robot.type: 从URL的robot.type参数获取扩展名
     */
    @Adaptive({"robot.type"})
    void sayHello(URL url);
    
    /**
     * 攻击方法
     * adaptiveKey: 从URL的attack.type参数获取扩展名
     */
    @Adaptive({"attack.type", "attack"})
    void attack(URL url);
} */`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

/**
 * 机器人扩展点接口
 * 
 * @SPI 注解标记这是一个扩展点
 * "default" 指定默认扩展实现名称
 */
@SPI("default")
public interface Robot {
    /**
     * 打招呼方法
     * @Adaptive 注解标记这是一个自适应方法
     * robot.type: 从URL的robot.type参数获取扩展名
     */
    @Adaptive({"robot.type"})
    void sayHello(URL url);
    
    /**
     * 攻击方法
     * adaptiveKey: 从URL的attack.type参数获取扩展名
     */
    @Adaptive({"attack.type", "attack"})
    void attack(URL url);
}@SPI("default")`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

/**
 * 机器人扩展点接口
 * 
 * @SPI 注解标记这是一个扩展点
 * "default" 指定默认扩展实现名称
 */
@SPI("default")
public interface Robot {
    /**
     * 打招呼方法
     * @Adaptive 注解标记这是一个自适应方法
     * robot.type: 从URL的robot.type参数获取扩展名
     */
    @Adaptive({"robot.type"})
    void sayHello(URL url);
    
    /**
     * 攻击方法
     * adaptiveKey: 从URL的attack.type参数获取扩展名
     */
    @Adaptive({"attack.type", "attack"})
    void attack(URL url);
}public interface Robot {`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

/**
 * 机器人扩展点接口
 * 
 * @SPI 注解标记这是一个扩展点
 * "default" 指定默认扩展实现名称
 */
@SPI("default")
public interface Robot {
    /**
     * 打招呼方法
     * @Adaptive 注解标记这是一个自适应方法
     * robot.type: 从URL的robot.type参数获取扩展名
     */
    @Adaptive({"robot.type"})
    void sayHello(URL url);
    
    /**
     * 攻击方法
     * adaptiveKey: 从URL的attack.type参数获取扩展名
     */
    @Adaptive({"attack.type", "attack"})
    void attack(URL url);
}    /**`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

/**
 * 机器人扩展点接口
 * 
 * @SPI 注解标记这是一个扩展点
 * "default" 指定默认扩展实现名称
 */
@SPI("default")
public interface Robot {
    /**
     * 打招呼方法
     * @Adaptive 注解标记这是一个自适应方法
     * robot.type: 从URL的robot.type参数获取扩展名
     */
    @Adaptive({"robot.type"})
    void sayHello(URL url);
    
    /**
     * 攻击方法
     * adaptiveKey: 从URL的attack.type参数获取扩展名
     */
    @Adaptive({"attack.type", "attack"})
    void attack(URL url);
}     * 打招呼方法`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

/**
 * 机器人扩展点接口
 * 
 * @SPI 注解标记这是一个扩展点
 * "default" 指定默认扩展实现名称
 */
@SPI("default")
public interface Robot {
    /**
     * 打招呼方法
     * @Adaptive 注解标记这是一个自适应方法
     * robot.type: 从URL的robot.type参数获取扩展名
     */
    @Adaptive({"robot.type"})
    void sayHello(URL url);
    
    /**
     * 攻击方法
     * adaptiveKey: 从URL的attack.type参数获取扩展名
     */
    @Adaptive({"attack.type", "attack"})
    void attack(URL url);
}     * @Adaptive 注解标记这是一个自适应方法`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

/**
 * 机器人扩展点接口
 * 
 * @SPI 注解标记这是一个扩展点
 * "default" 指定默认扩展实现名称
 */
@SPI("default")
public interface Robot {
    /**
     * 打招呼方法
     * @Adaptive 注解标记这是一个自适应方法
     * robot.type: 从URL的robot.type参数获取扩展名
     */
    @Adaptive({"robot.type"})
    void sayHello(URL url);
    
    /**
     * 攻击方法
     * adaptiveKey: 从URL的attack.type参数获取扩展名
     */
    @Adaptive({"attack.type", "attack"})
    void attack(URL url);
}     * robot.type: 从URL的robot.type参数获取扩展名`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

/**
 * 机器人扩展点接口
 * 
 * @SPI 注解标记这是一个扩展点
 * "default" 指定默认扩展实现名称
 */
@SPI("default")
public interface Robot {
    /**
     * 打招呼方法
     * @Adaptive 注解标记这是一个自适应方法
     * robot.type: 从URL的robot.type参数获取扩展名
     */
    @Adaptive({"robot.type"})
    void sayHello(URL url);
    
    /**
     * 攻击方法
     * adaptiveKey: 从URL的attack.type参数获取扩展名
     */
    @Adaptive({"attack.type", "attack"})
    void attack(URL url);
}     */`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

/**
 * 机器人扩展点接口
 * 
 * @SPI 注解标记这是一个扩展点
 * "default" 指定默认扩展实现名称
 */
@SPI("default")
public interface Robot {
    /**
     * 打招呼方法
     * @Adaptive 注解标记这是一个自适应方法
     * robot.type: 从URL的robot.type参数获取扩展名
     */
    @Adaptive({"robot.type"})
    void sayHello(URL url);
    
    /**
     * 攻击方法
     * adaptiveKey: 从URL的attack.type参数获取扩展名
     */
    @Adaptive({"attack.type", "attack"})
    void attack(URL url);
}    @Adaptive({"robot.type"})`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

/**
 * 机器人扩展点接口
 * 
 * @SPI 注解标记这是一个扩展点
 * "default" 指定默认扩展实现名称
 */
@SPI("default")
public interface Robot {
    /**
     * 打招呼方法
     * @Adaptive 注解标记这是一个自适应方法
     * robot.type: 从URL的robot.type参数获取扩展名
     */
    @Adaptive({"robot.type"})
    void sayHello(URL url);
    
    /**
     * 攻击方法
     * adaptiveKey: 从URL的attack.type参数获取扩展名
     */
    @Adaptive({"attack.type", "attack"})
    void attack(URL url);
}    void sayHello(URL url);`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

/**
 * 机器人扩展点接口
 * 
 * @SPI 注解标记这是一个扩展点
 * "default" 指定默认扩展实现名称
 */
@SPI("default")
public interface Robot {
    /**
     * 打招呼方法
     * @Adaptive 注解标记这是一个自适应方法
     * robot.type: 从URL的robot.type参数获取扩展名
     */
    @Adaptive({"robot.type"})
    void sayHello(URL url);
    
    /**
     * 攻击方法
     * adaptiveKey: 从URL的attack.type参数获取扩展名
     */
    @Adaptive({"attack.type", "attack"})
    void attack(URL url);
}    `
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

/**
 * 机器人扩展点接口
 * 
 * @SPI 注解标记这是一个扩展点
 * "default" 指定默认扩展实现名称
 */
@SPI("default")
public interface Robot {
    /**
     * 打招呼方法
     * @Adaptive 注解标记这是一个自适应方法
     * robot.type: 从URL的robot.type参数获取扩展名
     */
    @Adaptive({"robot.type"})
    void sayHello(URL url);
    
    /**
     * 攻击方法
     * adaptiveKey: 从URL的attack.type参数获取扩展名
     */
    @Adaptive({"attack.type", "attack"})
    void attack(URL url);
}    /**`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

/**
 * 机器人扩展点接口
 * 
 * @SPI 注解标记这是一个扩展点
 * "default" 指定默认扩展实现名称
 */
@SPI("default")
public interface Robot {
    /**
     * 打招呼方法
     * @Adaptive 注解标记这是一个自适应方法
     * robot.type: 从URL的robot.type参数获取扩展名
     */
    @Adaptive({"robot.type"})
    void sayHello(URL url);
    
    /**
     * 攻击方法
     * adaptiveKey: 从URL的attack.type参数获取扩展名
     */
    @Adaptive({"attack.type", "attack"})
    void attack(URL url);
}     * 攻击方法`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

/**
 * 机器人扩展点接口
 * 
 * @SPI 注解标记这是一个扩展点
 * "default" 指定默认扩展实现名称
 */
@SPI("default")
public interface Robot {
    /**
     * 打招呼方法
     * @Adaptive 注解标记这是一个自适应方法
     * robot.type: 从URL的robot.type参数获取扩展名
     */
    @Adaptive({"robot.type"})
    void sayHello(URL url);
    
    /**
     * 攻击方法
     * adaptiveKey: 从URL的attack.type参数获取扩展名
     */
    @Adaptive({"attack.type", "attack"})
    void attack(URL url);
}     * adaptiveKey: 从URL的attack.type参数获取扩展名`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

/**
 * 机器人扩展点接口
 * 
 * @SPI 注解标记这是一个扩展点
 * "default" 指定默认扩展实现名称
 */
@SPI("default")
public interface Robot {
    /**
     * 打招呼方法
     * @Adaptive 注解标记这是一个自适应方法
     * robot.type: 从URL的robot.type参数获取扩展名
     */
    @Adaptive({"robot.type"})
    void sayHello(URL url);
    
    /**
     * 攻击方法
     * adaptiveKey: 从URL的attack.type参数获取扩展名
     */
    @Adaptive({"attack.type", "attack"})
    void attack(URL url);
}     */`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

/**
 * 机器人扩展点接口
 * 
 * @SPI 注解标记这是一个扩展点
 * "default" 指定默认扩展实现名称
 */
@SPI("default")
public interface Robot {
    /**
     * 打招呼方法
     * @Adaptive 注解标记这是一个自适应方法
     * robot.type: 从URL的robot.type参数获取扩展名
     */
    @Adaptive({"robot.type"})
    void sayHello(URL url);
    
    /**
     * 攻击方法
     * adaptiveKey: 从URL的attack.type参数获取扩展名
     */
    @Adaptive({"attack.type", "attack"})
    void attack(URL url);
}    @Adaptive({"attack.type", "attack"})`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

/**
 * 机器人扩展点接口
 * 
 * @SPI 注解标记这是一个扩展点
 * "default" 指定默认扩展实现名称
 */
@SPI("default")
public interface Robot {
    /**
     * 打招呼方法
     * @Adaptive 注解标记这是一个自适应方法
     * robot.type: 从URL的robot.type参数获取扩展名
     */
    @Adaptive({"robot.type"})
    void sayHello(URL url);
    
    /**
     * 攻击方法
     * adaptiveKey: 从URL的attack.type参数获取扩展名
     */
    @Adaptive({"attack.type", "attack"})
    void attack(URL url);
}    void attack(URL url);`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

/**
 * 机器人扩展点接口
 * 
 * @SPI 注解标记这是一个扩展点
 * "default" 指定默认扩展实现名称
 */
@SPI("default")
public interface Robot {
    /**
     * 打招呼方法
     * @Adaptive 注解标记这是一个自适应方法
     * robot.type: 从URL的robot.type参数获取扩展名
     */
    @Adaptive({"robot.type"})
    void sayHello(URL url);
    
    /**
     * 攻击方法
     * adaptiveKey: 从URL的attack.type参数获取扩展名
     */
    @Adaptive({"attack.type", "attack"})
    void attack(URL url);
}}
步骤2: 实现扩展类
java 复制代码
#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现
 */
public class OptimusPrime implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱使用能量剑攻击!");
    }
}package com.example.dubbo.spi.impl;`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现
 */
public class OptimusPrime implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱使用能量剑攻击!");
    }
}`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现
 */
public class OptimusPrime implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱使用能量剑攻击!");
    }
}import com.example.dubbo.spi.Robot;`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现
 */
public class OptimusPrime implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱使用能量剑攻击!");
    }
}import org.apache.dubbo.common.URL;`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现
 */
public class OptimusPrime implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱使用能量剑攻击!");
    }
}`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现
 */
public class OptimusPrime implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱使用能量剑攻击!");
    }
}/**`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现
 */
public class OptimusPrime implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱使用能量剑攻击!");
    }
} * 擎天柱实现`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现
 */
public class OptimusPrime implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱使用能量剑攻击!");
    }
} */`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现
 */
public class OptimusPrime implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱使用能量剑攻击!");
    }
}public class OptimusPrime implements Robot {`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现
 */
public class OptimusPrime implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱使用能量剑攻击!");
    }
}    `
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现
 */
public class OptimusPrime implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱使用能量剑攻击!");
    }
}    @Override`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现
 */
public class OptimusPrime implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱使用能量剑攻击!");
    }
}    public void sayHello(URL url) {`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现
 */
public class OptimusPrime implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱使用能量剑攻击!");
    }
}        System.out.println("我是擎天柱,汽车人的领袖!");`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现
 */
public class OptimusPrime implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱使用能量剑攻击!");
    }
}        System.out.println("URL参数: " + url.getParameter("robot.type"));`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现
 */
public class OptimusPrime implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱使用能量剑攻击!");
    }
}    }`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现
 */
public class OptimusPrime implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱使用能量剑攻击!");
    }
}    `
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现
 */
public class OptimusPrime implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱使用能量剑攻击!");
    }
}    @Override`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现
 */
public class OptimusPrime implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱使用能量剑攻击!");
    }
}    public void attack(URL url) {`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现
 */
public class OptimusPrime implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱使用能量剑攻击!");
    }
}        System.out.println("擎天柱使用能量剑攻击!");`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现
 */
public class OptimusPrime implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱使用能量剑攻击!");
    }
}    }`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现
 */
public class OptimusPrime implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱使用能量剑攻击!");
    }
}}
java 复制代码
#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 大黄蜂实现
 */
public class Bumblebee implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是大黄蜂,最忠实的伙伴!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("大黄蜂使用电磁炮攻击!");
    }
}package com.example.dubbo.spi.impl;`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 大黄蜂实现
 */
public class Bumblebee implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是大黄蜂,最忠实的伙伴!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("大黄蜂使用电磁炮攻击!");
    }
}`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 大黄蜂实现
 */
public class Bumblebee implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是大黄蜂,最忠实的伙伴!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("大黄蜂使用电磁炮攻击!");
    }
}import com.example.dubbo.spi.Robot;`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 大黄蜂实现
 */
public class Bumblebee implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是大黄蜂,最忠实的伙伴!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("大黄蜂使用电磁炮攻击!");
    }
}import org.apache.dubbo.common.URL;`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 大黄蜂实现
 */
public class Bumblebee implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是大黄蜂,最忠实的伙伴!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("大黄蜂使用电磁炮攻击!");
    }
}`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 大黄蜂实现
 */
public class Bumblebee implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是大黄蜂,最忠实的伙伴!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("大黄蜂使用电磁炮攻击!");
    }
}/**`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 大黄蜂实现
 */
public class Bumblebee implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是大黄蜂,最忠实的伙伴!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("大黄蜂使用电磁炮攻击!");
    }
} * 大黄蜂实现`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 大黄蜂实现
 */
public class Bumblebee implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是大黄蜂,最忠实的伙伴!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("大黄蜂使用电磁炮攻击!");
    }
} */`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 大黄蜂实现
 */
public class Bumblebee implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是大黄蜂,最忠实的伙伴!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("大黄蜂使用电磁炮攻击!");
    }
}public class Bumblebee implements Robot {`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 大黄蜂实现
 */
public class Bumblebee implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是大黄蜂,最忠实的伙伴!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("大黄蜂使用电磁炮攻击!");
    }
}    `
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 大黄蜂实现
 */
public class Bumblebee implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是大黄蜂,最忠实的伙伴!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("大黄蜂使用电磁炮攻击!");
    }
}    @Override`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 大黄蜂实现
 */
public class Bumblebee implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是大黄蜂,最忠实的伙伴!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("大黄蜂使用电磁炮攻击!");
    }
}    public void sayHello(URL url) {`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 大黄蜂实现
 */
public class Bumblebee implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是大黄蜂,最忠实的伙伴!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("大黄蜂使用电磁炮攻击!");
    }
}        System.out.println("我是大黄蜂,最忠实的伙伴!");`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 大黄蜂实现
 */
public class Bumblebee implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是大黄蜂,最忠实的伙伴!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("大黄蜂使用电磁炮攻击!");
    }
}        System.out.println("URL参数: " + url.getParameter("robot.type"));`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 大黄蜂实现
 */
public class Bumblebee implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是大黄蜂,最忠实的伙伴!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("大黄蜂使用电磁炮攻击!");
    }
}    }`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 大黄蜂实现
 */
public class Bumblebee implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是大黄蜂,最忠实的伙伴!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("大黄蜂使用电磁炮攻击!");
    }
}    `
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 大黄蜂实现
 */
public class Bumblebee implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是大黄蜂,最忠实的伙伴!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("大黄蜂使用电磁炮攻击!");
    }
}    @Override`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 大黄蜂实现
 */
public class Bumblebee implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是大黄蜂,最忠实的伙伴!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("大黄蜂使用电磁炮攻击!");
    }
}    public void attack(URL url) {`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 大黄蜂实现
 */
public class Bumblebee implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是大黄蜂,最忠实的伙伴!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("大黄蜂使用电磁炮攻击!");
    }
}        System.out.println("大黄蜂使用电磁炮攻击!");`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 大黄蜂实现
 */
public class Bumblebee implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是大黄蜂,最忠实的伙伴!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("大黄蜂使用电磁炮攻击!");
    }
}    }`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 大黄蜂实现
 */
public class Bumblebee implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是大黄蜂,最忠实的伙伴!");
        System.out.println("URL参数: " + url.getParameter("robot.type"));
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("大黄蜂使用电磁炮攻击!");
    }
}}
java 复制代码
#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 默认机器人实现
 */
public class DefaultRobot implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是默认机器人,未指定具体类型!");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("默认机器人使用普通攻击!");
    }
}package com.example.dubbo.spi.impl;`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 默认机器人实现
 */
public class DefaultRobot implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是默认机器人,未指定具体类型!");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("默认机器人使用普通攻击!");
    }
}`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 默认机器人实现
 */
public class DefaultRobot implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是默认机器人,未指定具体类型!");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("默认机器人使用普通攻击!");
    }
}import com.example.dubbo.spi.Robot;`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 默认机器人实现
 */
public class DefaultRobot implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是默认机器人,未指定具体类型!");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("默认机器人使用普通攻击!");
    }
}import org.apache.dubbo.common.URL;`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 默认机器人实现
 */
public class DefaultRobot implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是默认机器人,未指定具体类型!");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("默认机器人使用普通攻击!");
    }
}`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 默认机器人实现
 */
public class DefaultRobot implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是默认机器人,未指定具体类型!");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("默认机器人使用普通攻击!");
    }
}/**`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 默认机器人实现
 */
public class DefaultRobot implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是默认机器人,未指定具体类型!");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("默认机器人使用普通攻击!");
    }
} * 默认机器人实现`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 默认机器人实现
 */
public class DefaultRobot implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是默认机器人,未指定具体类型!");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("默认机器人使用普通攻击!");
    }
} */`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 默认机器人实现
 */
public class DefaultRobot implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是默认机器人,未指定具体类型!");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("默认机器人使用普通攻击!");
    }
}public class DefaultRobot implements Robot {`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 默认机器人实现
 */
public class DefaultRobot implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是默认机器人,未指定具体类型!");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("默认机器人使用普通攻击!");
    }
}    `
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 默认机器人实现
 */
public class DefaultRobot implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是默认机器人,未指定具体类型!");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("默认机器人使用普通攻击!");
    }
}    @Override`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 默认机器人实现
 */
public class DefaultRobot implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是默认机器人,未指定具体类型!");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("默认机器人使用普通攻击!");
    }
}    public void sayHello(URL url) {`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 默认机器人实现
 */
public class DefaultRobot implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是默认机器人,未指定具体类型!");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("默认机器人使用普通攻击!");
    }
}        System.out.println("我是默认机器人,未指定具体类型!");`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 默认机器人实现
 */
public class DefaultRobot implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是默认机器人,未指定具体类型!");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("默认机器人使用普通攻击!");
    }
}    }`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 默认机器人实现
 */
public class DefaultRobot implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是默认机器人,未指定具体类型!");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("默认机器人使用普通攻击!");
    }
}    `
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 默认机器人实现
 */
public class DefaultRobot implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是默认机器人,未指定具体类型!");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("默认机器人使用普通攻击!");
    }
}    @Override`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 默认机器人实现
 */
public class DefaultRobot implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是默认机器人,未指定具体类型!");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("默认机器人使用普通攻击!");
    }
}    public void attack(URL url) {`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 默认机器人实现
 */
public class DefaultRobot implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是默认机器人,未指定具体类型!");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("默认机器人使用普通攻击!");
    }
}        System.out.println("默认机器人使用普通攻击!");`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 默认机器人实现
 */
public class DefaultRobot implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是默认机器人,未指定具体类型!");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("默认机器人使用普通攻击!");
    }
}    }`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 默认机器人实现
 */
public class DefaultRobot implements Robot {
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是默认机器人,未指定具体类型!");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("默认机器人使用普通攻击!");
    }
}}
步骤3: 创建 Wrapper 类(AOP)
java 复制代码
#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}package com.example.dubbo.spi.wrapper;`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}import com.example.dubbo.spi.Robot;`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}import org.apache.dubbo.common.URL;`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}/**`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
} * 日志记录Wrapper`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
} */`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}public class RobotLogWrapper implements Robot {`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}    `
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}    private Robot robot;`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}    `
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}    // 必须提供以扩展点接口为参数的构造函数`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}    public RobotLogWrapper(Robot robot) {`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}        this.robot = robot;`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}    }`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}    `
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}    @Override`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}    public void sayHello(URL url) {`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}        System.out.println("=== [LogWrapper] 方法调用开始 ===");`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}        long startTime = System.currentTimeMillis();`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}        `
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}        try {`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}            robot.sayHello(url);`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}        } finally {`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}            long endTime = System.currentTimeMillis();`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}        }`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}    }`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}    `
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}    @Override`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}    public void attack(URL url) {`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}        System.out.println("=== [LogWrapper] 准备攻击 ===");`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}        robot.attack(url);`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}        System.out.println("=== [LogWrapper] 攻击完成 ===");`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}    }`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 日志记录Wrapper
 */
public class RobotLogWrapper implements Robot {
    
    private Robot robot;
    
    // 必须提供以扩展点接口为参数的构造函数
    public RobotLogWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [LogWrapper] 方法调用开始 ===");
        long startTime = System.currentTimeMillis();
        
        try {
            robot.sayHello(url);
        } finally {
            long endTime = System.currentTimeMillis();
            System.out.println("=== [LogWrapper] 方法调用结束, 耗时: " + (endTime - startTime) + "ms ===");
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [LogWrapper] 准备攻击 ===");
        robot.attack(url);
        System.out.println("=== [LogWrapper] 攻击完成 ===");
    }
}}
java 复制代码
#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 性能监控Wrapper
 */
public class RobotMonitorWrapper implements Robot {
    
    private Robot robot;
    
    public RobotMonitorWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [MonitorWrapper] 监控数据收集开始 ===");
        robot.sayHello(url);
        System.out.println("=== [MonitorWrapper] 监控数据收集完成 ===");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [MonitorWrapper] 攻击性能监控 ===");
        robot.attack(url);
    }
}package com.example.dubbo.spi.wrapper;`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 性能监控Wrapper
 */
public class RobotMonitorWrapper implements Robot {
    
    private Robot robot;
    
    public RobotMonitorWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [MonitorWrapper] 监控数据收集开始 ===");
        robot.sayHello(url);
        System.out.println("=== [MonitorWrapper] 监控数据收集完成 ===");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [MonitorWrapper] 攻击性能监控 ===");
        robot.attack(url);
    }
}`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 性能监控Wrapper
 */
public class RobotMonitorWrapper implements Robot {
    
    private Robot robot;
    
    public RobotMonitorWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [MonitorWrapper] 监控数据收集开始 ===");
        robot.sayHello(url);
        System.out.println("=== [MonitorWrapper] 监控数据收集完成 ===");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [MonitorWrapper] 攻击性能监控 ===");
        robot.attack(url);
    }
}import com.example.dubbo.spi.Robot;`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 性能监控Wrapper
 */
public class RobotMonitorWrapper implements Robot {
    
    private Robot robot;
    
    public RobotMonitorWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [MonitorWrapper] 监控数据收集开始 ===");
        robot.sayHello(url);
        System.out.println("=== [MonitorWrapper] 监控数据收集完成 ===");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [MonitorWrapper] 攻击性能监控 ===");
        robot.attack(url);
    }
}import org.apache.dubbo.common.URL;`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 性能监控Wrapper
 */
public class RobotMonitorWrapper implements Robot {
    
    private Robot robot;
    
    public RobotMonitorWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [MonitorWrapper] 监控数据收集开始 ===");
        robot.sayHello(url);
        System.out.println("=== [MonitorWrapper] 监控数据收集完成 ===");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [MonitorWrapper] 攻击性能监控 ===");
        robot.attack(url);
    }
}`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 性能监控Wrapper
 */
public class RobotMonitorWrapper implements Robot {
    
    private Robot robot;
    
    public RobotMonitorWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [MonitorWrapper] 监控数据收集开始 ===");
        robot.sayHello(url);
        System.out.println("=== [MonitorWrapper] 监控数据收集完成 ===");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [MonitorWrapper] 攻击性能监控 ===");
        robot.attack(url);
    }
}/**`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 性能监控Wrapper
 */
public class RobotMonitorWrapper implements Robot {
    
    private Robot robot;
    
    public RobotMonitorWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [MonitorWrapper] 监控数据收集开始 ===");
        robot.sayHello(url);
        System.out.println("=== [MonitorWrapper] 监控数据收集完成 ===");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [MonitorWrapper] 攻击性能监控 ===");
        robot.attack(url);
    }
} * 性能监控Wrapper`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 性能监控Wrapper
 */
public class RobotMonitorWrapper implements Robot {
    
    private Robot robot;
    
    public RobotMonitorWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [MonitorWrapper] 监控数据收集开始 ===");
        robot.sayHello(url);
        System.out.println("=== [MonitorWrapper] 监控数据收集完成 ===");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [MonitorWrapper] 攻击性能监控 ===");
        robot.attack(url);
    }
} */`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 性能监控Wrapper
 */
public class RobotMonitorWrapper implements Robot {
    
    private Robot robot;
    
    public RobotMonitorWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [MonitorWrapper] 监控数据收集开始 ===");
        robot.sayHello(url);
        System.out.println("=== [MonitorWrapper] 监控数据收集完成 ===");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [MonitorWrapper] 攻击性能监控 ===");
        robot.attack(url);
    }
}public class RobotMonitorWrapper implements Robot {`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 性能监控Wrapper
 */
public class RobotMonitorWrapper implements Robot {
    
    private Robot robot;
    
    public RobotMonitorWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [MonitorWrapper] 监控数据收集开始 ===");
        robot.sayHello(url);
        System.out.println("=== [MonitorWrapper] 监控数据收集完成 ===");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [MonitorWrapper] 攻击性能监控 ===");
        robot.attack(url);
    }
}    `
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 性能监控Wrapper
 */
public class RobotMonitorWrapper implements Robot {
    
    private Robot robot;
    
    public RobotMonitorWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [MonitorWrapper] 监控数据收集开始 ===");
        robot.sayHello(url);
        System.out.println("=== [MonitorWrapper] 监控数据收集完成 ===");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [MonitorWrapper] 攻击性能监控 ===");
        robot.attack(url);
    }
}    private Robot robot;`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 性能监控Wrapper
 */
public class RobotMonitorWrapper implements Robot {
    
    private Robot robot;
    
    public RobotMonitorWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [MonitorWrapper] 监控数据收集开始 ===");
        robot.sayHello(url);
        System.out.println("=== [MonitorWrapper] 监控数据收集完成 ===");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [MonitorWrapper] 攻击性能监控 ===");
        robot.attack(url);
    }
}    `
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 性能监控Wrapper
 */
public class RobotMonitorWrapper implements Robot {
    
    private Robot robot;
    
    public RobotMonitorWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [MonitorWrapper] 监控数据收集开始 ===");
        robot.sayHello(url);
        System.out.println("=== [MonitorWrapper] 监控数据收集完成 ===");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [MonitorWrapper] 攻击性能监控 ===");
        robot.attack(url);
    }
}    public RobotMonitorWrapper(Robot robot) {`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 性能监控Wrapper
 */
public class RobotMonitorWrapper implements Robot {
    
    private Robot robot;
    
    public RobotMonitorWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [MonitorWrapper] 监控数据收集开始 ===");
        robot.sayHello(url);
        System.out.println("=== [MonitorWrapper] 监控数据收集完成 ===");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [MonitorWrapper] 攻击性能监控 ===");
        robot.attack(url);
    }
}        this.robot = robot;`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 性能监控Wrapper
 */
public class RobotMonitorWrapper implements Robot {
    
    private Robot robot;
    
    public RobotMonitorWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [MonitorWrapper] 监控数据收集开始 ===");
        robot.sayHello(url);
        System.out.println("=== [MonitorWrapper] 监控数据收集完成 ===");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [MonitorWrapper] 攻击性能监控 ===");
        robot.attack(url);
    }
}    }`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 性能监控Wrapper
 */
public class RobotMonitorWrapper implements Robot {
    
    private Robot robot;
    
    public RobotMonitorWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [MonitorWrapper] 监控数据收集开始 ===");
        robot.sayHello(url);
        System.out.println("=== [MonitorWrapper] 监控数据收集完成 ===");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [MonitorWrapper] 攻击性能监控 ===");
        robot.attack(url);
    }
}    `
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 性能监控Wrapper
 */
public class RobotMonitorWrapper implements Robot {
    
    private Robot robot;
    
    public RobotMonitorWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [MonitorWrapper] 监控数据收集开始 ===");
        robot.sayHello(url);
        System.out.println("=== [MonitorWrapper] 监控数据收集完成 ===");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [MonitorWrapper] 攻击性能监控 ===");
        robot.attack(url);
    }
}    @Override`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 性能监控Wrapper
 */
public class RobotMonitorWrapper implements Robot {
    
    private Robot robot;
    
    public RobotMonitorWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [MonitorWrapper] 监控数据收集开始 ===");
        robot.sayHello(url);
        System.out.println("=== [MonitorWrapper] 监控数据收集完成 ===");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [MonitorWrapper] 攻击性能监控 ===");
        robot.attack(url);
    }
}    public void sayHello(URL url) {`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 性能监控Wrapper
 */
public class RobotMonitorWrapper implements Robot {
    
    private Robot robot;
    
    public RobotMonitorWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [MonitorWrapper] 监控数据收集开始 ===");
        robot.sayHello(url);
        System.out.println("=== [MonitorWrapper] 监控数据收集完成 ===");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [MonitorWrapper] 攻击性能监控 ===");
        robot.attack(url);
    }
}        System.out.println("=== [MonitorWrapper] 监控数据收集开始 ===");`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 性能监控Wrapper
 */
public class RobotMonitorWrapper implements Robot {
    
    private Robot robot;
    
    public RobotMonitorWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [MonitorWrapper] 监控数据收集开始 ===");
        robot.sayHello(url);
        System.out.println("=== [MonitorWrapper] 监控数据收集完成 ===");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [MonitorWrapper] 攻击性能监控 ===");
        robot.attack(url);
    }
}        robot.sayHello(url);`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 性能监控Wrapper
 */
public class RobotMonitorWrapper implements Robot {
    
    private Robot robot;
    
    public RobotMonitorWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [MonitorWrapper] 监控数据收集开始 ===");
        robot.sayHello(url);
        System.out.println("=== [MonitorWrapper] 监控数据收集完成 ===");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [MonitorWrapper] 攻击性能监控 ===");
        robot.attack(url);
    }
}        System.out.println("=== [MonitorWrapper] 监控数据收集完成 ===");`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 性能监控Wrapper
 */
public class RobotMonitorWrapper implements Robot {
    
    private Robot robot;
    
    public RobotMonitorWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [MonitorWrapper] 监控数据收集开始 ===");
        robot.sayHello(url);
        System.out.println("=== [MonitorWrapper] 监控数据收集完成 ===");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [MonitorWrapper] 攻击性能监控 ===");
        robot.attack(url);
    }
}    }`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 性能监控Wrapper
 */
public class RobotMonitorWrapper implements Robot {
    
    private Robot robot;
    
    public RobotMonitorWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [MonitorWrapper] 监控数据收集开始 ===");
        robot.sayHello(url);
        System.out.println("=== [MonitorWrapper] 监控数据收集完成 ===");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [MonitorWrapper] 攻击性能监控 ===");
        robot.attack(url);
    }
}    `
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 性能监控Wrapper
 */
public class RobotMonitorWrapper implements Robot {
    
    private Robot robot;
    
    public RobotMonitorWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [MonitorWrapper] 监控数据收集开始 ===");
        robot.sayHello(url);
        System.out.println("=== [MonitorWrapper] 监控数据收集完成 ===");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [MonitorWrapper] 攻击性能监控 ===");
        robot.attack(url);
    }
}    @Override`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 性能监控Wrapper
 */
public class RobotMonitorWrapper implements Robot {
    
    private Robot robot;
    
    public RobotMonitorWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [MonitorWrapper] 监控数据收集开始 ===");
        robot.sayHello(url);
        System.out.println("=== [MonitorWrapper] 监控数据收集完成 ===");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [MonitorWrapper] 攻击性能监控 ===");
        robot.attack(url);
    }
}    public void attack(URL url) {`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 性能监控Wrapper
 */
public class RobotMonitorWrapper implements Robot {
    
    private Robot robot;
    
    public RobotMonitorWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [MonitorWrapper] 监控数据收集开始 ===");
        robot.sayHello(url);
        System.out.println("=== [MonitorWrapper] 监控数据收集完成 ===");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [MonitorWrapper] 攻击性能监控 ===");
        robot.attack(url);
    }
}        System.out.println("=== [MonitorWrapper] 攻击性能监控 ===");`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 性能监控Wrapper
 */
public class RobotMonitorWrapper implements Robot {
    
    private Robot robot;
    
    public RobotMonitorWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [MonitorWrapper] 监控数据收集开始 ===");
        robot.sayHello(url);
        System.out.println("=== [MonitorWrapper] 监控数据收集完成 ===");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [MonitorWrapper] 攻击性能监控 ===");
        robot.attack(url);
    }
}        robot.attack(url);`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 性能监控Wrapper
 */
public class RobotMonitorWrapper implements Robot {
    
    private Robot robot;
    
    public RobotMonitorWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [MonitorWrapper] 监控数据收集开始 ===");
        robot.sayHello(url);
        System.out.println("=== [MonitorWrapper] 监控数据收集完成 ===");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [MonitorWrapper] 攻击性能监控 ===");
        robot.attack(url);
    }
}    }`
`#package com.example.dubbo.spi.wrapper;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;

/**
 * 性能监控Wrapper
 */
public class RobotMonitorWrapper implements Robot {
    
    private Robot robot;
    
    public RobotMonitorWrapper(Robot robot) {
        this.robot = robot;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("=== [MonitorWrapper] 监控数据收集开始 ===");
        robot.sayHello(url);
        System.out.println("=== [MonitorWrapper] 监控数据收集完成 ===");
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("=== [MonitorWrapper] 攻击性能监控 ===");
        robot.attack(url);
    }
}}
步骤4: 配置文件

META-INF/dubbo/com.example.dubbo.spi.Robot 文件中配置:

复制代码
# 扩展实现
optimusPrime=com.example.dubbo.spi.impl.OptimusPrime
bumblebee=com.example.dubbo.spi.impl.Bumblebee
default=com.example.dubbo.spi.impl.DefaultRobot

# Wrapper类(会自动识别,顺序影响包装顺序)
logWrapper=com.example.dubbo.spi.wrapper.RobotLogWrapper
monitorWrapper=com.example.dubbo.spi.wrapper.RobotMonitorWrapper
步骤5: 测试代码
java 复制代码
#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}package com.example.dubbo.test;`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}import com.example.dubbo.spi.Robot;`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}import org.apache.dubbo.common.URL;`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}import org.apache.dubbo.common.extension.ExtensionLoader;`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}/**`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
} * Dubbo SPI 测试类`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
} */`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}public class DubboSPITest {`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}    `
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}    public static void main(String[] args) {`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        // 1. 获取ExtensionLoader实例`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        `
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        // 测试1: 获取默认扩展`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        System.out.println("========== 测试1: 默认扩展 ==========");`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        Robot defaultRobot = loader.getDefaultExtension();`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        System.out.println();`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        `
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        // 测试2: 获取指定扩展`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        Robot optimusPrime = loader.getExtension("optimusPrime");`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        System.out.println();`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        `
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        // 测试3: 自适应扩展(动态选择)`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        System.out.println("========== 测试3: 自适应扩展 ==========");`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        Robot adaptiveRobot = loader.getAdaptiveExtension();`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        `
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        // 通过URL参数指定使用擎天柱`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        System.out.println("URL参数: robot.type=optimusPrime");`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        adaptiveRobot.sayHello(url1);`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        System.out.println();`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        `
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        // 通过URL参数指定使用大黄蜂`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        System.out.println("URL参数: robot.type=bumblebee");`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        adaptiveRobot.sayHello(url2);`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        System.out.println();`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        `
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        // 测试4: Wrapper包装效果`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        System.out.println("========== 测试4: Wrapper包装效果 ==========");`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        System.out.println("注意观察Wrapper的层层包装顺序!");`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        Robot wrappedRobot = loader.getExtension("optimusPrime");`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}    }`
`#package com.example.dubbo.test;

import com.example.dubbo.spi.Robot;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * Dubbo SPI 测试类
 */
public class DubboSPITest {
    
    public static void main(String[] args) {
        // 1. 获取ExtensionLoader实例
        ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
        
        // 测试1: 获取默认扩展
        System.out.println("========== 测试1: 默认扩展 ==========");
        Robot defaultRobot = loader.getDefaultExtension();
        defaultRobot.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试2: 获取指定扩展
        System.out.println("========== 测试2: 指定扩展(擎天柱) ==========");
        Robot optimusPrime = loader.getExtension("optimusPrime");
        optimusPrime.sayHello(URL.valueOf("dubbo://localhost:20880"));
        System.out.println();
        
        // 测试3: 自适应扩展(动态选择)
        System.out.println("========== 测试3: 自适应扩展 ==========");
        Robot adaptiveRobot = loader.getAdaptiveExtension();
        
        // 通过URL参数指定使用擎天柱
        URL url1 = URL.valueOf("dubbo://localhost:20880?robot.type=optimusPrime");
        System.out.println("URL参数: robot.type=optimusPrime");
        adaptiveRobot.sayHello(url1);
        System.out.println();
        
        // 通过URL参数指定使用大黄蜂
        URL url2 = URL.valueOf("dubbo://localhost:20880?robot.type=bumblebee");
        System.out.println("URL参数: robot.type=bumblebee");
        adaptiveRobot.sayHello(url2);
        System.out.println();
        
        // 测试4: Wrapper包装效果
        System.out.println("========== 测试4: Wrapper包装效果 ==========");
        System.out.println("注意观察Wrapper的层层包装顺序!");
        Robot wrappedRobot = loader.getExtension("optimusPrime");
        wrappedRobot.attack(URL.valueOf("dubbo://localhost:20880"));
    }
}}

预期输出:

复制代码
========== 测试1: 默认扩展 ==========
=== [MonitorWrapper] 监控数据收集开始 ===
=== [LogWrapper] 方法调用开始 ===
我是默认机器人,未指定具体类型!
=== [LogWrapper] 方法调用结束, 耗时: 0ms ===
=== [MonitorWrapper] 监控数据收集完成 ===

========== 测试2: 指定扩展(擎天柱) ==========
=== [MonitorWrapper] 监控数据收集开始 ===
=== [LogWrapper] 方法调用开始 ===
我是擎天柱,汽车人的领袖!
URL参数: null
=== [LogWrapper] 方法调用结束, 耗时: 1ms ===
=== [MonitorWrapper] 监控数据收集完成 ===

========== 测试3: 自适应扩展 ==========
URL参数: robot.type=optimusPrime
=== [MonitorWrapper] 监控数据收集开始 ===
=== [LogWrapper] 方法调用开始 ===
我是擎天柱,汽车人的领袖!
URL参数: optimusPrime
=== [LogWrapper] 方法调用结束, 耗时: 0ms ===
=== [MonitorWrapper] 监控数据收集完成 ===

URL参数: robot.type=bumblebee
=== [MonitorWrapper] 监控数据收集开始 ===
=== [LogWrapper] 方法调用开始 ===
我是大黄蜂,最忠实的伙伴!
URL参数: bumblebee
=== [LogWrapper] 方法调用结束, 耗时: 0ms ===
=== [MonitorWrapper] 监控数据收集完成 ===

========== 测试4: Wrapper包装效果 ==========
注意观察Wrapper的层层包装顺序!
=== [MonitorWrapper] 攻击性能监控 ===
=== [LogWrapper] 准备攻击 ===
擎天柱使用能量剑攻击!
=== [LogWrapper] 攻击完成 ===

7.2 IOC 依赖注入实战

让我们演示扩展点之间的依赖注入:

定义Weapon扩展点:

java 复制代码
#package com.example.dubbo.spi;

import org.apache.dubbo.common.extension.SPI;

/**
 * 武器扩展点
 */
@SPI("sword")
public interface Weapon {
    void attack();
}package com.example.dubbo.spi;`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.extension.SPI;

/**
 * 武器扩展点
 */
@SPI("sword")
public interface Weapon {
    void attack();
}`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.extension.SPI;

/**
 * 武器扩展点
 */
@SPI("sword")
public interface Weapon {
    void attack();
}import org.apache.dubbo.common.extension.SPI;`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.extension.SPI;

/**
 * 武器扩展点
 */
@SPI("sword")
public interface Weapon {
    void attack();
}`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.extension.SPI;

/**
 * 武器扩展点
 */
@SPI("sword")
public interface Weapon {
    void attack();
}/**`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.extension.SPI;

/**
 * 武器扩展点
 */
@SPI("sword")
public interface Weapon {
    void attack();
} * 武器扩展点`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.extension.SPI;

/**
 * 武器扩展点
 */
@SPI("sword")
public interface Weapon {
    void attack();
} */`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.extension.SPI;

/**
 * 武器扩展点
 */
@SPI("sword")
public interface Weapon {
    void attack();
}@SPI("sword")`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.extension.SPI;

/**
 * 武器扩展点
 */
@SPI("sword")
public interface Weapon {
    void attack();
}public interface Weapon {`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.extension.SPI;

/**
 * 武器扩展点
 */
@SPI("sword")
public interface Weapon {
    void attack();
}    void attack();`
`#package com.example.dubbo.spi;

import org.apache.dubbo.common.extension.SPI;

/**
 * 武器扩展点
 */
@SPI("sword")
public interface Weapon {
    void attack();
}}

武器实现类:

java 复制代码
#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Weapon;

/**
 * 能量剑
 */
public class EnergySword implements Weapon {
    @Override
    public void attack() {
        System.out.println("⚔️ 使用能量剑进行强力攻击!");
    }
}

/**
 * 离子炮
 */
public class IonCannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("💥 发射离子炮,威力巨大!");
    }
}package com.example.dubbo.spi.impl;`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Weapon;

/**
 * 能量剑
 */
public class EnergySword implements Weapon {
    @Override
    public void attack() {
        System.out.println("⚔️ 使用能量剑进行强力攻击!");
    }
}

/**
 * 离子炮
 */
public class IonCannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("💥 发射离子炮,威力巨大!");
    }
}`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Weapon;

/**
 * 能量剑
 */
public class EnergySword implements Weapon {
    @Override
    public void attack() {
        System.out.println("⚔️ 使用能量剑进行强力攻击!");
    }
}

/**
 * 离子炮
 */
public class IonCannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("💥 发射离子炮,威力巨大!");
    }
}import com.example.dubbo.spi.Weapon;`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Weapon;

/**
 * 能量剑
 */
public class EnergySword implements Weapon {
    @Override
    public void attack() {
        System.out.println("⚔️ 使用能量剑进行强力攻击!");
    }
}

/**
 * 离子炮
 */
public class IonCannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("💥 发射离子炮,威力巨大!");
    }
}`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Weapon;

/**
 * 能量剑
 */
public class EnergySword implements Weapon {
    @Override
    public void attack() {
        System.out.println("⚔️ 使用能量剑进行强力攻击!");
    }
}

/**
 * 离子炮
 */
public class IonCannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("💥 发射离子炮,威力巨大!");
    }
}/**`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Weapon;

/**
 * 能量剑
 */
public class EnergySword implements Weapon {
    @Override
    public void attack() {
        System.out.println("⚔️ 使用能量剑进行强力攻击!");
    }
}

/**
 * 离子炮
 */
public class IonCannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("💥 发射离子炮,威力巨大!");
    }
} * 能量剑`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Weapon;

/**
 * 能量剑
 */
public class EnergySword implements Weapon {
    @Override
    public void attack() {
        System.out.println("⚔️ 使用能量剑进行强力攻击!");
    }
}

/**
 * 离子炮
 */
public class IonCannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("💥 发射离子炮,威力巨大!");
    }
} */`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Weapon;

/**
 * 能量剑
 */
public class EnergySword implements Weapon {
    @Override
    public void attack() {
        System.out.println("⚔️ 使用能量剑进行强力攻击!");
    }
}

/**
 * 离子炮
 */
public class IonCannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("💥 发射离子炮,威力巨大!");
    }
}public class EnergySword implements Weapon {`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Weapon;

/**
 * 能量剑
 */
public class EnergySword implements Weapon {
    @Override
    public void attack() {
        System.out.println("⚔️ 使用能量剑进行强力攻击!");
    }
}

/**
 * 离子炮
 */
public class IonCannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("💥 发射离子炮,威力巨大!");
    }
}    @Override`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Weapon;

/**
 * 能量剑
 */
public class EnergySword implements Weapon {
    @Override
    public void attack() {
        System.out.println("⚔️ 使用能量剑进行强力攻击!");
    }
}

/**
 * 离子炮
 */
public class IonCannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("💥 发射离子炮,威力巨大!");
    }
}    public void attack() {`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Weapon;

/**
 * 能量剑
 */
public class EnergySword implements Weapon {
    @Override
    public void attack() {
        System.out.println("⚔️ 使用能量剑进行强力攻击!");
    }
}

/**
 * 离子炮
 */
public class IonCannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("💥 发射离子炮,威力巨大!");
    }
}        System.out.println("⚔️ 使用能量剑进行强力攻击!");`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Weapon;

/**
 * 能量剑
 */
public class EnergySword implements Weapon {
    @Override
    public void attack() {
        System.out.println("⚔️ 使用能量剑进行强力攻击!");
    }
}

/**
 * 离子炮
 */
public class IonCannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("💥 发射离子炮,威力巨大!");
    }
}    }`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Weapon;

/**
 * 能量剑
 */
public class EnergySword implements Weapon {
    @Override
    public void attack() {
        System.out.println("⚔️ 使用能量剑进行强力攻击!");
    }
}

/**
 * 离子炮
 */
public class IonCannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("💥 发射离子炮,威力巨大!");
    }
}}`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Weapon;

/**
 * 能量剑
 */
public class EnergySword implements Weapon {
    @Override
    public void attack() {
        System.out.println("⚔️ 使用能量剑进行强力攻击!");
    }
}

/**
 * 离子炮
 */
public class IonCannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("💥 发射离子炮,威力巨大!");
    }
}`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Weapon;

/**
 * 能量剑
 */
public class EnergySword implements Weapon {
    @Override
    public void attack() {
        System.out.println("⚔️ 使用能量剑进行强力攻击!");
    }
}

/**
 * 离子炮
 */
public class IonCannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("💥 发射离子炮,威力巨大!");
    }
}/**`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Weapon;

/**
 * 能量剑
 */
public class EnergySword implements Weapon {
    @Override
    public void attack() {
        System.out.println("⚔️ 使用能量剑进行强力攻击!");
    }
}

/**
 * 离子炮
 */
public class IonCannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("💥 发射离子炮,威力巨大!");
    }
} * 离子炮`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Weapon;

/**
 * 能量剑
 */
public class EnergySword implements Weapon {
    @Override
    public void attack() {
        System.out.println("⚔️ 使用能量剑进行强力攻击!");
    }
}

/**
 * 离子炮
 */
public class IonCannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("💥 发射离子炮,威力巨大!");
    }
} */`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Weapon;

/**
 * 能量剑
 */
public class EnergySword implements Weapon {
    @Override
    public void attack() {
        System.out.println("⚔️ 使用能量剑进行强力攻击!");
    }
}

/**
 * 离子炮
 */
public class IonCannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("💥 发射离子炮,威力巨大!");
    }
}public class IonCannon implements Weapon {`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Weapon;

/**
 * 能量剑
 */
public class EnergySword implements Weapon {
    @Override
    public void attack() {
        System.out.println("⚔️ 使用能量剑进行强力攻击!");
    }
}

/**
 * 离子炮
 */
public class IonCannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("💥 发射离子炮,威力巨大!");
    }
}    @Override`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Weapon;

/**
 * 能量剑
 */
public class EnergySword implements Weapon {
    @Override
    public void attack() {
        System.out.println("⚔️ 使用能量剑进行强力攻击!");
    }
}

/**
 * 离子炮
 */
public class IonCannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("💥 发射离子炮,威力巨大!");
    }
}    public void attack() {`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Weapon;

/**
 * 能量剑
 */
public class EnergySword implements Weapon {
    @Override
    public void attack() {
        System.out.println("⚔️ 使用能量剑进行强力攻击!");
    }
}

/**
 * 离子炮
 */
public class IonCannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("💥 发射离子炮,威力巨大!");
    }
}        System.out.println("💥 发射离子炮,威力巨大!");`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Weapon;

/**
 * 能量剑
 */
public class EnergySword implements Weapon {
    @Override
    public void attack() {
        System.out.println("⚔️ 使用能量剑进行强力攻击!");
    }
}

/**
 * 离子炮
 */
public class IonCannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("💥 发射离子炮,威力巨大!");
    }
}    }`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Weapon;

/**
 * 能量剑
 */
public class EnergySword implements Weapon {
    @Override
    public void attack() {
        System.out.println("⚔️ 使用能量剑进行强力攻击!");
    }
}

/**
 * 离子炮
 */
public class IonCannon implements Weapon {
    @Override
    public void attack() {
        System.out.println("💥 发射离子炮,威力巨大!");
    }
}}

修改Robot实现,添加Weapon依赖:

java 复制代码
#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}package com.example.dubbo.spi.impl;`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}import com.example.dubbo.spi.Robot;`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}import com.example.dubbo.spi.Weapon;`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}import org.apache.dubbo.common.URL;`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}/**`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
} * 擎天柱实现 - 带武器依赖`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
} */`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}public class OptimusPrime implements Robot {`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}    `
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}    private Weapon weapon; // 通过setter注入`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}    `
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}    // setter方法: Dubbo SPI会自动注入`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}    public void setWeapon(Weapon weapon) {`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}        this.weapon = weapon;`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}    }`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}    `
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}    @Override`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}    public void sayHello(URL url) {`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}        System.out.println("我是擎天柱,汽车人的领袖!");`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}        if (weapon != null) {`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}            System.out.print("我的武器是: ");`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}            weapon.attack();`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}        }`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}    }`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}    `
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}    @Override`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}    public void attack(URL url) {`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}        System.out.println("擎天柱发起攻击!");`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}        if (weapon != null) {`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}            weapon.attack();`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}        } else {`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}            System.out.println("没有武器,使用拳头!");`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}        }`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}    }`
`#package com.example.dubbo.spi.impl;

import com.example.dubbo.spi.Robot;
import com.example.dubbo.spi.Weapon;
import org.apache.dubbo.common.URL;

/**
 * 擎天柱实现 - 带武器依赖
 */
public class OptimusPrime implements Robot {
    
    private Weapon weapon; // 通过setter注入
    
    // setter方法: Dubbo SPI会自动注入
    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    
    @Override
    public void sayHello(URL url) {
        System.out.println("我是擎天柱,汽车人的领袖!");
        if (weapon != null) {
            System.out.print("我的武器是: ");
            weapon.attack();
        }
    }
    
    @Override
    public void attack(URL url) {
        System.out.println("擎天柱发起攻击!");
        if (weapon != null) {
            weapon.attack();
        } else {
            System.out.println("没有武器,使用拳头!");
        }
    }
}}

Weapon配置文件: META-INF/dubbo/com.example.dubbo.spi.Weapon

复制代码
sword=com.example.dubbo.spi.impl.EnergySword
cannon=com.example.dubbo.spi.impl.IonCannon

IOC测试代码:

java 复制代码
#// IOC依赖注入测试
ExtensionLoader<Robot> robotLoader = ExtensionLoader.getExtensionLoader(Robot.class);
Robot optimusPrime = robotLoader.getExtension("optimusPrime");

// 调用方法,观察weapon是否被自动注入
optimusPrime.attack(URL.valueOf("dubbo://localhost:20880"));

// 预期输出:
// === [MonitorWrapper] 攻击性能监控 ===
// === [LogWrapper] 准备攻击 ===
// 擎天柱发起攻击!
// ⚔️ 使用能量剑进行强力攻击!  <-- weapon被自动注入!
// === [LogWrapper] 攻击完成 ===// IOC依赖注入测试`
`#// IOC依赖注入测试
ExtensionLoader<Robot> robotLoader = ExtensionLoader.getExtensionLoader(Robot.class);
Robot optimusPrime = robotLoader.getExtension("optimusPrime");

// 调用方法,观察weapon是否被自动注入
optimusPrime.attack(URL.valueOf("dubbo://localhost:20880"));

// 预期输出:
// === [MonitorWrapper] 攻击性能监控 ===
// === [LogWrapper] 准备攻击 ===
// 擎天柱发起攻击!
// ⚔️ 使用能量剑进行强力攻击!  <-- weapon被自动注入!
// === [LogWrapper] 攻击完成 ===ExtensionLoader<Robot> robotLoader = ExtensionLoader.getExtensionLoader(Robot.class);`
`#// IOC依赖注入测试
ExtensionLoader<Robot> robotLoader = ExtensionLoader.getExtensionLoader(Robot.class);
Robot optimusPrime = robotLoader.getExtension("optimusPrime");

// 调用方法,观察weapon是否被自动注入
optimusPrime.attack(URL.valueOf("dubbo://localhost:20880"));

// 预期输出:
// === [MonitorWrapper] 攻击性能监控 ===
// === [LogWrapper] 准备攻击 ===
// 擎天柱发起攻击!
// ⚔️ 使用能量剑进行强力攻击!  <-- weapon被自动注入!
// === [LogWrapper] 攻击完成 ===Robot optimusPrime = robotLoader.getExtension("optimusPrime");`
`#// IOC依赖注入测试
ExtensionLoader<Robot> robotLoader = ExtensionLoader.getExtensionLoader(Robot.class);
Robot optimusPrime = robotLoader.getExtension("optimusPrime");

// 调用方法,观察weapon是否被自动注入
optimusPrime.attack(URL.valueOf("dubbo://localhost:20880"));

// 预期输出:
// === [MonitorWrapper] 攻击性能监控 ===
// === [LogWrapper] 准备攻击 ===
// 擎天柱发起攻击!
// ⚔️ 使用能量剑进行强力攻击!  <-- weapon被自动注入!
// === [LogWrapper] 攻击完成 ===`
`#// IOC依赖注入测试
ExtensionLoader<Robot> robotLoader = ExtensionLoader.getExtensionLoader(Robot.class);
Robot optimusPrime = robotLoader.getExtension("optimusPrime");

// 调用方法,观察weapon是否被自动注入
optimusPrime.attack(URL.valueOf("dubbo://localhost:20880"));

// 预期输出:
// === [MonitorWrapper] 攻击性能监控 ===
// === [LogWrapper] 准备攻击 ===
// 擎天柱发起攻击!
// ⚔️ 使用能量剑进行强力攻击!  <-- weapon被自动注入!
// === [LogWrapper] 攻击完成 ===// 调用方法,观察weapon是否被自动注入`
`#// IOC依赖注入测试
ExtensionLoader<Robot> robotLoader = ExtensionLoader.getExtensionLoader(Robot.class);
Robot optimusPrime = robotLoader.getExtension("optimusPrime");

// 调用方法,观察weapon是否被自动注入
optimusPrime.attack(URL.valueOf("dubbo://localhost:20880"));

// 预期输出:
// === [MonitorWrapper] 攻击性能监控 ===
// === [LogWrapper] 准备攻击 ===
// 擎天柱发起攻击!
// ⚔️ 使用能量剑进行强力攻击!  <-- weapon被自动注入!
// === [LogWrapper] 攻击完成 ===optimusPrime.attack(URL.valueOf("dubbo://localhost:20880"));`
`#// IOC依赖注入测试
ExtensionLoader<Robot> robotLoader = ExtensionLoader.getExtensionLoader(Robot.class);
Robot optimusPrime = robotLoader.getExtension("optimusPrime");

// 调用方法,观察weapon是否被自动注入
optimusPrime.attack(URL.valueOf("dubbo://localhost:20880"));

// 预期输出:
// === [MonitorWrapper] 攻击性能监控 ===
// === [LogWrapper] 准备攻击 ===
// 擎天柱发起攻击!
// ⚔️ 使用能量剑进行强力攻击!  <-- weapon被自动注入!
// === [LogWrapper] 攻击完成 ===`
`#// IOC依赖注入测试
ExtensionLoader<Robot> robotLoader = ExtensionLoader.getExtensionLoader(Robot.class);
Robot optimusPrime = robotLoader.getExtension("optimusPrime");

// 调用方法,观察weapon是否被自动注入
optimusPrime.attack(URL.valueOf("dubbo://localhost:20880"));

// 预期输出:
// === [MonitorWrapper] 攻击性能监控 ===
// === [LogWrapper] 准备攻击 ===
// 擎天柱发起攻击!
// ⚔️ 使用能量剑进行强力攻击!  <-- weapon被自动注入!
// === [LogWrapper] 攻击完成 ===// 预期输出:`
`#// IOC依赖注入测试
ExtensionLoader<Robot> robotLoader = ExtensionLoader.getExtensionLoader(Robot.class);
Robot optimusPrime = robotLoader.getExtension("optimusPrime");

// 调用方法,观察weapon是否被自动注入
optimusPrime.attack(URL.valueOf("dubbo://localhost:20880"));

// 预期输出:
// === [MonitorWrapper] 攻击性能监控 ===
// === [LogWrapper] 准备攻击 ===
// 擎天柱发起攻击!
// ⚔️ 使用能量剑进行强力攻击!  <-- weapon被自动注入!
// === [LogWrapper] 攻击完成 ===// === [MonitorWrapper] 攻击性能监控 ===`
`#// IOC依赖注入测试
ExtensionLoader<Robot> robotLoader = ExtensionLoader.getExtensionLoader(Robot.class);
Robot optimusPrime = robotLoader.getExtension("optimusPrime");

// 调用方法,观察weapon是否被自动注入
optimusPrime.attack(URL.valueOf("dubbo://localhost:20880"));

// 预期输出:
// === [MonitorWrapper] 攻击性能监控 ===
// === [LogWrapper] 准备攻击 ===
// 擎天柱发起攻击!
// ⚔️ 使用能量剑进行强力攻击!  <-- weapon被自动注入!
// === [LogWrapper] 攻击完成 ===// === [LogWrapper] 准备攻击 ===`
`#// IOC依赖注入测试
ExtensionLoader<Robot> robotLoader = ExtensionLoader.getExtensionLoader(Robot.class);
Robot optimusPrime = robotLoader.getExtension("optimusPrime");

// 调用方法,观察weapon是否被自动注入
optimusPrime.attack(URL.valueOf("dubbo://localhost:20880"));

// 预期输出:
// === [MonitorWrapper] 攻击性能监控 ===
// === [LogWrapper] 准备攻击 ===
// 擎天柱发起攻击!
// ⚔️ 使用能量剑进行强力攻击!  <-- weapon被自动注入!
// === [LogWrapper] 攻击完成 ===// 擎天柱发起攻击!`
`#// IOC依赖注入测试
ExtensionLoader<Robot> robotLoader = ExtensionLoader.getExtensionLoader(Robot.class);
Robot optimusPrime = robotLoader.getExtension("optimusPrime");

// 调用方法,观察weapon是否被自动注入
optimusPrime.attack(URL.valueOf("dubbo://localhost:20880"));

// 预期输出:
// === [MonitorWrapper] 攻击性能监控 ===
// === [LogWrapper] 准备攻击 ===
// 擎天柱发起攻击!
// ⚔️ 使用能量剑进行强力攻击!  <-- weapon被自动注入!
// === [LogWrapper] 攻击完成 ===// ⚔️ 使用能量剑进行强力攻击!  <-- weapon被自动注入!`
`#// IOC依赖注入测试
ExtensionLoader<Robot> robotLoader = ExtensionLoader.getExtensionLoader(Robot.class);
Robot optimusPrime = robotLoader.getExtension("optimusPrime");

// 调用方法,观察weapon是否被自动注入
optimusPrime.attack(URL.valueOf("dubbo://localhost:20880"));

// 预期输出:
// === [MonitorWrapper] 攻击性能监控 ===
// === [LogWrapper] 准备攻击 ===
// 擎天柱发起攻击!
// ⚔️ 使用能量剑进行强力攻击!  <-- weapon被自动注入!
// === [LogWrapper] 攻击完成 ===// === [LogWrapper] 攻击完成 ===

IOC依赖注入流程图:

复制代码
sequenceDiagram
    participant Test
    participant EL_Robot as ExtensionLoader<Robot>
    participant EF as ExtensionFactory
    participant EL_Weapon as ExtensionLoader<Weapon>
    
    Test->>EL_Robot: getExtension("optimusPrime")
    EL_Robot->>EL_Robot: createExtension()
    EL_Robot->>EL_Robot: 创建OptimusPrime实例
    
    EL_Robot->>EL_Robot: injectExtension()
    EL_Robot->>EL_Robot: 遍历setter方法
    
    alt 发现setWeapon方法
        EL_Robot->>EF: getExtension(Weapon.class, "weapon")
        EF->>EL_Weapon: getExtension("sword")
        EL_Weapon->>EL_Weapon: 加载配置,查找默认实现
        EL_Weapon-->>EF: 返回EnergySword实例
        EF-->>EL_Robot: 返回EnergySword实例
        EL_Robot->>EL_Robot: 反射调用setWeapon()
    end
    
    EL_Robot->>EL_Robot: 应用Wrapper包装
    EL_Robot-->>Test: 返回注入完成的OptimusPrime

八、Dubbo SPI 最佳实践

8.1 设计原则

表 8-1: Dubbo SPI 设计最佳实践
原则 说明 示例
单一职责 每个扩展类只负责一个功能 Protocol扩展只负责协议通信
接口隔离 扩展点接口应该精简,避免臃肿 将Protocol和Transporter分离
开闭原则 对扩展开放,对修改关闭 新增协议只需实现Protocol接口
依赖倒置 依赖抽象而非具体实现 依赖Robot接口而非OptimusPrime类
配置外部化 扩展配置放在外部文件中 META-INF/dubbo/目录下的配置

8.2 命名规范

扩展点接口命名: - 使用名词,表示能力或功能 - 示例: ProtocolLoadBalanceCluster

扩展实现类命名: - 使用具体实现名称 + 接口名称 - 示例: DubboProtocolRandomLoadBalanceFailoverCluster

扩展别名命名: - 使用小写,多个单词用连字符分隔 - 示例: dubborandomfailover

8.3 常见陷阱与解决方案

表 8-2: Dubbo SPI 常见问题及解决方案
问题 原因 解决方案
扩展加载失败 配置文件路径错误 检查是否在 META-INF/dubbo/ 目录下
依赖注入失败 setter方法命名不规范 使用标准setXxx命名
Wrapper不生效 Wrapper类构造函数错误 确保有以扩展点接口为参数的构造函数
自适应扩展失效 @Adaptive注解配置错误 检查URL参数名是否匹配
类冲突 多个jar包包含同名配置 使用 overridden 属性控制覆盖
死锁 扩展之间循环依赖 重新设计扩展依赖关系

8.4 性能优化建议

  1. 合理使用缓存

    java 复制代码
    #// ✅ 好的做法: 复用ExtensionLoader实例
    ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
    Robot robot1 = loader.getExtension("optimusPrime");
    Robot robot2 = loader.getExtension("optimusPrime"); // 使用缓存
    
    // ❌ 不好的做法: 每次都创建新实例
    ExtensionLoader<Robot> loader1 = ExtensionLoader.getExtensionLoader(Robot.class);
    ExtensionLoader<Robot> loader2 = ExtensionLoader.getExtensionLoader(Robot.class);// ✅ 好的做法: 复用ExtensionLoader实例`
    `#// ✅ 好的做法: 复用ExtensionLoader实例
    ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
    Robot robot1 = loader.getExtension("optimusPrime");
    Robot robot2 = loader.getExtension("optimusPrime"); // 使用缓存
    
    // ❌ 不好的做法: 每次都创建新实例
    ExtensionLoader<Robot> loader1 = ExtensionLoader.getExtensionLoader(Robot.class);
    ExtensionLoader<Robot> loader2 = ExtensionLoader.getExtensionLoader(Robot.class);ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);`
    `#// ✅ 好的做法: 复用ExtensionLoader实例
    ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
    Robot robot1 = loader.getExtension("optimusPrime");
    Robot robot2 = loader.getExtension("optimusPrime"); // 使用缓存
    
    // ❌ 不好的做法: 每次都创建新实例
    ExtensionLoader<Robot> loader1 = ExtensionLoader.getExtensionLoader(Robot.class);
    ExtensionLoader<Robot> loader2 = ExtensionLoader.getExtensionLoader(Robot.class);Robot robot1 = loader.getExtension("optimusPrime");`
    `#// ✅ 好的做法: 复用ExtensionLoader实例
    ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
    Robot robot1 = loader.getExtension("optimusPrime");
    Robot robot2 = loader.getExtension("optimusPrime"); // 使用缓存
    
    // ❌ 不好的做法: 每次都创建新实例
    ExtensionLoader<Robot> loader1 = ExtensionLoader.getExtensionLoader(Robot.class);
    ExtensionLoader<Robot> loader2 = ExtensionLoader.getExtensionLoader(Robot.class);Robot robot2 = loader.getExtension("optimusPrime"); // 使用缓存`
    `#// ✅ 好的做法: 复用ExtensionLoader实例
    ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
    Robot robot1 = loader.getExtension("optimusPrime");
    Robot robot2 = loader.getExtension("optimusPrime"); // 使用缓存
    
    // ❌ 不好的做法: 每次都创建新实例
    ExtensionLoader<Robot> loader1 = ExtensionLoader.getExtensionLoader(Robot.class);
    ExtensionLoader<Robot> loader2 = ExtensionLoader.getExtensionLoader(Robot.class);`
    `#// ✅ 好的做法: 复用ExtensionLoader实例
    ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
    Robot robot1 = loader.getExtension("optimusPrime");
    Robot robot2 = loader.getExtension("optimusPrime"); // 使用缓存
    
    // ❌ 不好的做法: 每次都创建新实例
    ExtensionLoader<Robot> loader1 = ExtensionLoader.getExtensionLoader(Robot.class);
    ExtensionLoader<Robot> loader2 = ExtensionLoader.getExtensionLoader(Robot.class);// ❌ 不好的做法: 每次都创建新实例`
    `#// ✅ 好的做法: 复用ExtensionLoader实例
    ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
    Robot robot1 = loader.getExtension("optimusPrime");
    Robot robot2 = loader.getExtension("optimusPrime"); // 使用缓存
    
    // ❌ 不好的做法: 每次都创建新实例
    ExtensionLoader<Robot> loader1 = ExtensionLoader.getExtensionLoader(Robot.class);
    ExtensionLoader<Robot> loader2 = ExtensionLoader.getExtensionLoader(Robot.class);ExtensionLoader<Robot> loader1 = ExtensionLoader.getExtensionLoader(Robot.class);`
    `#// ✅ 好的做法: 复用ExtensionLoader实例
    ExtensionLoader<Robot> loader = ExtensionLoader.getExtensionLoader(Robot.class);
    Robot robot1 = loader.getExtension("optimusPrime");
    Robot robot2 = loader.getExtension("optimusPrime"); // 使用缓存
    
    // ❌ 不好的做法: 每次都创建新实例
    ExtensionLoader<Robot> loader1 = ExtensionLoader.getExtensionLoader(Robot.class);
    ExtensionLoader<Robot> loader2 = ExtensionLoader.getExtensionLoader(Robot.class);ExtensionLoader<Robot> loader2 = ExtensionLoader.getExtensionLoader(Robot.class);
  2. 延迟初始化

    java 复制代码
    #// ✅ 好的做法: 按需加载
    private volatile Robot robot;
    
    public Robot getRobot() {
        if (robot == null) {
            synchronized (this) {
                if (robot == null) {
                    robot = ExtensionLoader.getExtensionLoader(Robot.class)
                        .getExtension("optimusPrime");
                }
            }
        }
        return robot;
    }// ✅ 好的做法: 按需加载`
    `#// ✅ 好的做法: 按需加载
    private volatile Robot robot;
    
    public Robot getRobot() {
        if (robot == null) {
            synchronized (this) {
                if (robot == null) {
                    robot = ExtensionLoader.getExtensionLoader(Robot.class)
                        .getExtension("optimusPrime");
                }
            }
        }
        return robot;
    }private volatile Robot robot;`
    `#// ✅ 好的做法: 按需加载
    private volatile Robot robot;
    
    public Robot getRobot() {
        if (robot == null) {
            synchronized (this) {
                if (robot == null) {
                    robot = ExtensionLoader.getExtensionLoader(Robot.class)
                        .getExtension("optimusPrime");
                }
            }
        }
        return robot;
    }`
    `#// ✅ 好的做法: 按需加载
    private volatile Robot robot;
    
    public Robot getRobot() {
        if (robot == null) {
            synchronized (this) {
                if (robot == null) {
                    robot = ExtensionLoader.getExtensionLoader(Robot.class)
                        .getExtension("optimusPrime");
                }
            }
        }
        return robot;
    }public Robot getRobot() {`
    `#// ✅ 好的做法: 按需加载
    private volatile Robot robot;
    
    public Robot getRobot() {
        if (robot == null) {
            synchronized (this) {
                if (robot == null) {
                    robot = ExtensionLoader.getExtensionLoader(Robot.class)
                        .getExtension("optimusPrime");
                }
            }
        }
        return robot;
    }    if (robot == null) {`
    `#// ✅ 好的做法: 按需加载
    private volatile Robot robot;
    
    public Robot getRobot() {
        if (robot == null) {
            synchronized (this) {
                if (robot == null) {
                    robot = ExtensionLoader.getExtensionLoader(Robot.class)
                        .getExtension("optimusPrime");
                }
            }
        }
        return robot;
    }        synchronized (this) {`
    `#// ✅ 好的做法: 按需加载
    private volatile Robot robot;
    
    public Robot getRobot() {
        if (robot == null) {
            synchronized (this) {
                if (robot == null) {
                    robot = ExtensionLoader.getExtensionLoader(Robot.class)
                        .getExtension("optimusPrime");
                }
            }
        }
        return robot;
    }            if (robot == null) {`
    `#// ✅ 好的做法: 按需加载
    private volatile Robot robot;
    
    public Robot getRobot() {
        if (robot == null) {
            synchronized (this) {
                if (robot == null) {
                    robot = ExtensionLoader.getExtensionLoader(Robot.class)
                        .getExtension("optimusPrime");
                }
            }
        }
        return robot;
    }                robot = ExtensionLoader.getExtensionLoader(Robot.class)`
    `#// ✅ 好的做法: 按需加载
    private volatile Robot robot;
    
    public Robot getRobot() {
        if (robot == null) {
            synchronized (this) {
                if (robot == null) {
                    robot = ExtensionLoader.getExtensionLoader(Robot.class)
                        .getExtension("optimusPrime");
                }
            }
        }
        return robot;
    }                    .getExtension("optimusPrime");`
    `#// ✅ 好的做法: 按需加载
    private volatile Robot robot;
    
    public Robot getRobot() {
        if (robot == null) {
            synchronized (this) {
                if (robot == null) {
                    robot = ExtensionLoader.getExtensionLoader(Robot.class)
                        .getExtension("optimusPrime");
                }
            }
        }
        return robot;
    }            }`
    `#// ✅ 好的做法: 按需加载
    private volatile Robot robot;
    
    public Robot getRobot() {
        if (robot == null) {
            synchronized (this) {
                if (robot == null) {
                    robot = ExtensionLoader.getExtensionLoader(Robot.class)
                        .getExtension("optimusPrime");
                }
            }
        }
        return robot;
    }        }`
    `#// ✅ 好的做法: 按需加载
    private volatile Robot robot;
    
    public Robot getRobot() {
        if (robot == null) {
            synchronized (this) {
                if (robot == null) {
                    robot = ExtensionLoader.getExtensionLoader(Robot.class)
                        .getExtension("optimusPrime");
                }
            }
        }
        return robot;
    }    }`
    `#// ✅ 好的做法: 按需加载
    private volatile Robot robot;
    
    public Robot getRobot() {
        if (robot == null) {
            synchronized (this) {
                if (robot == null) {
                    robot = ExtensionLoader.getExtensionLoader(Robot.class)
                        .getExtension("optimusPrime");
                }
            }
        }
        return robot;
    }    return robot;`
    `#// ✅ 好的做法: 按需加载
    private volatile Robot robot;
    
    public Robot getRobot() {
        if (robot == null) {
            synchronized (this) {
                if (robot == null) {
                    robot = ExtensionLoader.getExtensionLoader(Robot.class)
                        .getExtension("optimusPrime");
                }
            }
        }
        return robot;
    }}
  3. Wrapper顺序优化

    复制代码
    # 配置文件中Wrapper的顺序影响执行顺序
    # 建议将监控、日志等通用Wrapper放在前面
    monitorWrapper=com.example.MonitorWrapper
    logWrapper=com.example.LogWrapper
    cacheWrapper=com.example.CacheWrapper

九、总结

9.1 核心要点回顾

通过本文的深入学习,我们掌握了 Dubbo SPI 的核心知识:

表 9-1: Dubbo SPI 核心知识点总结
知识点 核心内容 关键类/注解
SPI基础 服务提供者接口,动态扩展机制 @SPI
ExtensionLoader 扩展加载器,负责加载、缓存、注入 ExtensionLoader
IOC机制 通过setter方法注入依赖 ExtensionFactory
AOP机制 通过Wrapper类实现切面编程 Wrapper
自适应扩展 根据URL参数动态选择实现 @Adaptive
激活扩展 根据条件自动激活扩展 @Activate

9.2 与其他框架对比

表 9-2: 主流框架SPI机制对比
特性 Dubbo SPI Spring Factories Java SPI
配置路径 META-INF/dubbo/ META-INF/spring.factories META-INF/services/
IOC支持
AOP支持 ✅ (Wrapper) ✅ (AOP)
自适应
条件激活
懒加载
使用场景 RPC框架扩展 Spring Boot自动配置 通用服务发现

9.3 学习建议

  1. 动手实践
    • 自己实现一个完整的Dubbo SPI示例
    • 尝试自定义Dubbo的LoadBalance扩展
  2. 源码阅读
    • 重点关注 ExtensionLoader.java 的核心方法
    • 理解 AdaptiveClassCodeGenerator 的代码生成逻辑
  3. 实际应用
    • 在项目中合理使用Dubbo SPI进行扩展
    • 学习Dubbo官方扩展的实现方式

9.4 参考资料


结语

Dubbo SPI 机制是 Dubbo 框架的基石,通过本文的学习,您应该已经掌握了:

ExtensionLoader 的工作原理 - 从配置加载到实例创建的完整流程

IOC 和 AOP 的实现方式 - 通过依赖注入和包装类实现解耦

自适应扩展的奥秘 - 运行时动态选择实现类的机制

实战应用能力 - 能够在实际项目中自定义Dubbo扩展

Dubbo SPI 的设计精髓在于: 通过约定优于配置的思想,实现了高度的可扩展性和灵活性,这正是优秀框架设计的体现。

希望本文能够帮助您深入理解 Dubbo SPI,并在实际项目中灵活运用!


标签: Dubbo SPI ExtensionLoader 微服务 源码解析

作者: AI技术助手
发布时间: 2024年
源码版本: Dubbo 3.2.9

相关推荐
蝎子莱莱爱打怪3 天前
XZLL-IM干货系列 04|Netty 长连接实战:Pipeline 怎么排、心跳怎么跳、连接怎么管
后端·微服务·面试
SamDeepThinking4 天前
Java微服务练习方式
java·后端·微服务
米丘7 天前
微前端之 Web Components 完全指南
微服务·html
霸道流氓气质10 天前
领域驱动设计(DDD)在 Spring Boot 微服务中的实践指南
运维·spring boot·微服务
牛根生同志10 天前
SPI数据收发的时候 TXE与RXNE标志位置位的时机
stm32·spi·transfer
AI模力圈10 天前
FSDP 源码解析:初始化与显存分配
分布式训练·源码解析·fsdp
zhuzicc10 天前
Dubbo @Autowired 注入同模块接口,到底走的是本地调用还是 RPC?源码给你答案(Dubbo @Service注解的双重注册机制)
rpc·autowired·dubbo·依赖注入·java面试·spring ioc·dubbo源码分析
霸道流氓气质10 天前
Spring Boot 微服务性能优化完全指南
spring boot·微服务·性能优化
地瓜伯伯10 天前
从MESI缓存一致性协议讲透synchronized的底层
java·spring boot·spring·spring cloud·微服务·springcloud
Devin~Y10 天前
大厂 Java 面试实录:从音视频内容社区到 AI RAG 的全链路技术设计
java·spring boot·redis·spring cloud·微服务·kafka·音视频