You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.2 KiB
35 lines
1.2 KiB
package cc.bnblogs.beanstudy.bean; |
|
|
|
import org.springframework.beans.BeansException; |
|
import org.springframework.beans.PropertyValues; |
|
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor; |
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
@Component |
|
public class MyBeanInstantiationPostProcessor implements InstantiationAwareBeanPostProcessor { |
|
|
|
@Override |
|
public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException { |
|
if ("beanStudyApplication".equals(beanName)) { |
|
System.out.println("post process before " + beanName + " instantiation"); |
|
} |
|
return null; |
|
} |
|
|
|
@Override |
|
public boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException { |
|
if ("beanStudyApplication".equals(beanName)) { |
|
System.out.println("post process after " + beanName + " instantiation"); |
|
} |
|
return true; |
|
} |
|
|
|
@Override |
|
public PropertyValues postProcessProperties(PropertyValues pvs, Object bean, String beanName) throws BeansException { |
|
if ("beanStudyApplication".equals(beanName)) { |
|
System.out.println("post process " + beanName + " properties"); |
|
} |
|
return pvs; |
|
} |
|
} |