本文整理汇总了Java中org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor.postProcessBeforeInstantiation方法的典型用法代码示例。如果您正苦于以下问题:Java InstantiationAwareBeanPostProcessor.postProcessBeforeInstantiation方法的具体用法?Java InstantiationAwareBeanPostProcessor.postProcessBeforeInstantiation怎么用?Java InstantiationAwareBeanPostProcessor.postProcessBeforeInstantiation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor
的用法示例。
在下文中一共展示了InstantiationAwareBeanPostProcessor.postProcessBeforeInstantiation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyBeanPostProcessorsBeforeInstantiation
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor; //导入方法依赖的package包/类
/**
* Apply InstantiationAwareBeanPostProcessors to the specified bean definition
* (by class and name), invoking their {@code postProcessBeforeInstantiation} methods.
* <p>Any returned object will be used as the bean instead of actually instantiating
* the target bean. A {@code null} return value from the post-processor will
* result in the target bean being instantiated.
* @param beanClass the class of the bean to be instantiated
* @param beanName the name of the bean
* @return the bean object to use instead of a default instance of the target bean, or {@code null}
* @throws BeansException if any post-processing failed
* @see InstantiationAwareBeanPostProcessor#postProcessBeforeInstantiation
*/
protected Object applyBeanPostProcessorsBeforeInstantiation(Class<?> beanClass, String beanName)
throws BeansException {
for (BeanPostProcessor bp : getBeanPostProcessors()) {
if (bp instanceof InstantiationAwareBeanPostProcessor) {
InstantiationAwareBeanPostProcessor ibp = (InstantiationAwareBeanPostProcessor) bp;
Object result = ibp.postProcessBeforeInstantiation(beanClass, beanName);
if (result != null) {
return result;
}
}
}
return null;
}