spring扩展点六:监听spring容器刷新事件

本文介绍了Spring在初始化过程中发送的容器刷新事件作为一个扩展点,可以通过监听该事件在容器刷新完成后执行自定义业务逻辑。Dubbo服务提供者利用此扩展点,在容器刷新后进行服务暴露,通过监听ContextRefreshEvent事件来启动服务暴露的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在spring初始化的流程中,会发送一个容器刷新事件,这个事件,也是一个扩展点之一
先来看下发送刷新事件的源码

org.springframework.context.support.AbstractApplicationContext#refresh
  org.springframework.context.support.AbstractApplicationContext#finishRefresh

从这个方法的注释中,就可以知道这个方法是干什么的
/**
 * Finish the refresh of this context, invoking the LifecycleProcessor's
 * onRefresh() method and publishing the
 * {@link org.springframework.context.event.ContextRefreshedEvent}.
 */
 protected void finishRefresh() 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值