zoukankan      html  css  js  c++  java
  • Spring容器相关扩展点

    // 如果容器内的bean实现了该接口,那么在容器中实例化任何其他bean之前都会回调该方法来对bean的配置元数据进行修改
    public interface BeanFactoryPostProcessor {
        void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException;
    }
    
    // 通知接口
    public interface Aware {
    
    }
    
    // 常用:
    // - BeanNameAware
    // - BeanFactoryAware
    // - BeanClassLoaderAware
    // - ApplicationContextAware
    
    // 如果容器内的bean实现了该接口,那么在容器实例化该bean之后,执行初始化方法前/后调用
    public interface BeanPostProcessor {
        // call before initMethod
        default Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
            return bean;
        }
    
        // call after initMethod
        default Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
            return bean;
        }
    }
    
    // 如果bean实现了该接口,那么容器会在实例化完成后调用afterPropertiesSet方法进行一些初始化
    public interface InitializingBean {
        void afterPropertiesSet() throws Exception;
    }
    
    // 如果bean实现了该接口,容器会在bean实例销毁之前调用destory方法,来完成一些回收工作
    public interface DisposableBean {
        void destroy() throws Exception;
    }
    

    参考:https://www.cnblogs.com/v1haoge/p/6106456.html

  • 相关阅读:
    hdu 5045 Contest
    hdu 4068 SanguoSHA
    TSP 旅行商问题(状态压缩dp)
    haoi2015 树上操作
    noi 2015 软件包管理器(树链剖分)
    zjoi2008 树链剖分
    读入优化
    动态规划类型总结
    有关Rujia Liu 动态规划的·一些总结
    输入优化
  • 原文地址:https://www.cnblogs.com/jieyuefeng/p/11701554.html
Copyright © 2011-2022 走看看