spring 扩展点

一.初始化

  • @PostConstruct

  •  org.springframework.beans.factory.InitializingBean 接口

    void afterPropertiesSet()

  •   init-method 属性

二.注销

  •   @PreDestroy
  • org.springframework.beans.factory.DisposableBean 接口

    void destroy() throws Exception;

  •  destroy-method属性

三.容器启动和关闭(Startup and shutdown callbacks )

    publicinterface Lifecycle {

    void start();

    void stop();

    boolean isRunning();

}
    (附:正确关闭非web的spring容器:        AbstractApplicationContext.registerShutdownHook())

四. 感知容器

public interface ApplicationContextAware {

    void setApplicationContext(ApplicationContext applicationContext) throws BeansException;

}

 

  public interface ApplicationContextAware}   
 void setApplicationContext(ApplicationContext applicationContext) throws BeansException;
}

  ServletConfigAware

  ServletContextAware

messagesourceAware可感知国际化信息

五. 容器扩展点

  • org.springframework.beans.factory.config.BeanPostProcessor 

When such a class is registered as a post-processor with the container, for each bean instance that is created by the container, the post-processor gets a callback from the container both before container initialization methods (such as InitializingBean’s afterPropertiesSet() and any declared init method) are called as well as after any bean initialization callbacks

  •  org.springframework.beans.factory.config.BeanFactoryPostProcessor

BeanFactoryPostProcessor operates on the bean configuration metadata; that is, the Spring IoC container allows a BeanFactoryPostProcessor to read the configuration metadata and potentially change it before the container instantiates any beans other than BeanFactoryPostProcessors.

   -------》PropertyPlaceholderConfigurer,PropertyOverrideConfigurer

 

 

 

 

 

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值