Spring中Bean实例化之后做的增强 InstantiationAwareBeanPostProcessor

package sping.analysis.postprocessor;

import java.beans.PropertyDescriptor;

import org.springframework.beans.BeansException;
import org.springframework.beans.PropertyValues;
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter;
import org.springframework.stereotype.Component;

/**
 * Bean实例化之后做的增强
 * 
 * @author slHuang
 * @since 2019-02-12
 */
@Component
public class MyInstantiationAwareBeanPostProcessor extends InstantiationAwareBeanPostProcessorAdapter {
	
	@Override
	public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {
		System.out.println(this.getClass().getName() + ".postProcessBeforeInstantiation()被调用 了...");
		return super.postProcessBeforeInstantiation(beanClass, beanName);
	}
	
	@Override
	public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
		System.out.println(this.getClass().getName() + ".postProcessAfterInitialization()被调用 了...");
		return super.postProcessAfterInitialization(bean, beanName);
	}
	
	@Override
	public PropertyValues postProcessProperties(PropertyValues pvs, Object bean, String beanName)
			throws BeansException {
		System.out.println(this.getClass().getName() + ".postProcessProperties()被调用 了...");
		return super.postProcessProperties(pvs, bean, beanName);
	}
	
	@Override
	public PropertyValues postProcessPropertyValues(PropertyValues pvs, PropertyDescriptor[] pds, Object bean,
			String beanName) throws BeansException {
		System.out.println(this.getClass().getName() + ".postProcessPropertyValues()被调用 了...");
		return super.postProcessPropertyValues(pvs, pds, bean, beanName);
	}
}

你可能感兴趣的:(Spring,java)