zoukankan      html  css  js  c++  java
  • 生命周期-BeanPostProcessor-后置处理器

    通过实现BeanPostProcessor-后置处理器接口来实现bean在执行初始化方法(此时bean的属性已被赋值)前后的处理工作。

    public class MyBeanPostProcessor implements BeanPostProcessor {
    
        public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
            System.out.println("postProcessBeforeInitialization......"+ bean +"==>" + beanName);
            return bean;
        }
    
        public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
    
            System.out.println("postProcessAfterInitialization...... "+ bean +"==>" + beanName);
            return bean;
        }
    }
    postProcessBeforeInitialization......org.springframework.context.event.EventListenerMethodProcessor@6166e06f==>org.springframework.context.event.internalEventListenerProcessor
    postProcessAfterInitialization...... org.springframework.context.event.EventListenerMethodProcessor@6166e06f==>org.springframework.context.event.internalEventListenerProcessor
    postProcessBeforeInitialization......org.springframework.context.event.DefaultEventListenerFactory@1c72da34==>org.springframework.context.event.internalEventListenerFactory
    postProcessAfterInitialization...... org.springframework.context.event.DefaultEventListenerFactory@1c72da34==>org.springframework.context.event.internalEventListenerFactory
    postProcessBeforeInitialization......com.yyc.config.MainConfigOfLifeCycle$$EnhancerBySpringCGLIB$$3dbdcd18@6e38921c==>mainConfigOfLifeCycle
    postProcessAfterInitialization...... com.yyc.config.MainConfigOfLifeCycle$$EnhancerBySpringCGLIB$$3dbdcd18@6e38921c==>mainConfigOfLifeCycle
    car construct ....
    postProcessBeforeInitialization......com.yyc.bean.Car@4450d156==>car
    init method
    postProcessAfterInitialization...... com.yyc.bean.Car@4450d156==>car
    容器创建完成
    五月 24, 2019 3:24:34 下午 org.springframework.context.annotation.AnnotationConfigApplicationContext doClose
    信息: Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@4141d797: startup date [Fri May 24 15:24:34 CST 2019]; root of context hierarchy
    destroy method
  • 相关阅读:
    MvcApplication 中方法的那点事
    Html 中阻止事件冒泡的三种方法比较
    WPF中 ItemsSource 和DataContext不同点
    解决:Visual Studio 启动就报错退出
    webapi是如何绑定参数的(How WebAPI does Parameter Binding)
    %cd% 和%~dp0%的区别及cd跨盘符切换路径问题
    win10中matlabR2015b安装libsvm
    MATLAB2015b链接MinGW编译器
    网易内推编程题:异或运算求混合颜料的最小种类
    小易喜欢的单词
  • 原文地址:https://www.cnblogs.com/AyasatoMayoi/p/10918407.html
Copyright © 2011-2022 走看看