Spring Framwork 扩展点总结
接口 | 扩展描述 | 典型场景 |
---|---|---|
BeanFactoryPostProcessor | 对 BeanDefinition 进行修改 | Class 定义的 Bean,@Configuration 和 @Bean |
BeanPostProcessor | 对 Spring Bean 进行修改 | @Resource 通过反射进行依赖注入 |
FactoryBean | 使用 Class 定义 Bean | Spring 3.0 出现 @Configuration 和 @Bean 的复杂度高的 Bean 创建方式 |
XXXAware | 容器感知类 | ApplicationContextAware(获取 Bean)、ApplicationEventPublisherAware(事件发布) |
InitializingBean | Spring Bean 初始化回调函数 | 添加 Bean 的初始化操作或者必要参数的非空校验 |
DisposableBean | Spring Bean 销毁回调函数 | ScheduledTaskRegistrar(线程池任务删除) |
NamespaceHandler | xml 命名空间处理类 | <mvc:annotation-driven> 或 <dubbo:provider> |
Converter | 类型转换 | Spring IOC 初始化自动类型转换,可以使用 GenericConversionService 来业务对象转换 |
Spring Event | 消息事件 | 生产者/消费者 解耦 |
Condition | 条件表达式 | Spring Boot 自动依赖,也可自行扩展 |
还没有评论,来说两句吧...