Spring容器-新发现

通过  MethodInvokingFactoryBean 来实现静态方法或者对象初始化调用

<bean  class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"/>
       <property name="targetClass"  value="具体的Class对象"/>
       <property name="targetMethod"  value="init方法"/>    可以是静态方法调用
        <property name="arguments"  ref="引用对象"/>
</bean>
 Spring容器启动对象初始化顺序

 Constructor
 ->BeanNameAware:setBeanName回调
 ->BeanFactoryAware:setBeanFactory回调
 ->ApplicationContextAware:setApplicationContext(回调)
 ->BeanPostProcessor:postProcessBeforeInitialization(Object bean, String beanName)回调
 ->PostConstructor注解方法执行
 ->InitializingBean:afterPropertiesSet()回调
 ->XML init-method 
 ->BeanPostProcessor:postProcessAfterInitialization(Object bean, String beanName)->业务方法
 ->PreDestroy注解方法执行
 ->DisposableBean:destroy方法执行
 ->XML destroy-method

猜你喜欢

转载自blog.csdn.net/u011121287/article/details/87868863