use of org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource in project spring-framework by spring-projects.
the class AbstractBeanFactoryBasedTargetSourceCreator method getTargetSource.
//---------------------------------------------------------------------
// Implementation of the TargetSourceCreator interface
//---------------------------------------------------------------------
@Override
public final TargetSource getTargetSource(Class<?> beanClass, String beanName) {
AbstractBeanFactoryBasedTargetSource targetSource = createBeanFactoryBasedTargetSource(beanClass, beanName);
if (targetSource == null) {
return null;
}
if (logger.isDebugEnabled()) {
logger.debug("Configuring AbstractBeanFactoryBasedTargetSource: " + targetSource);
}
DefaultListableBeanFactory internalBeanFactory = getInternalBeanFactoryForBean(beanName);
// We need to override just this bean definition, as it may reference other beans
// and we're happy to take the parent's definition for those.
// Always use prototype scope if demanded.
BeanDefinition bd = this.beanFactory.getMergedBeanDefinition(beanName);
GenericBeanDefinition bdCopy = new GenericBeanDefinition(bd);
if (isPrototypeBased()) {
bdCopy.setScope(BeanDefinition.SCOPE_PROTOTYPE);
}
internalBeanFactory.registerBeanDefinition(beanName, bdCopy);
// Complete configuring the PrototypeTargetSource.
targetSource.setTargetBeanName(beanName);
targetSource.setBeanFactory(internalBeanFactory);
return targetSource;
}
Aggregations