use of cn.taketoday.aop.target.AbstractBeanFactoryTargetSource in project today-framework by TAKETODAY.
the class AbstractBeanFactoryTargetSourceCreator method getTargetSource.
// ---------------------------------------------------------------------
// Implementation of the TargetSourceCreator interface
// ---------------------------------------------------------------------
@Override
@Nullable
public final TargetSource getTargetSource(Class<?> beanClass, String beanName) {
AbstractBeanFactoryTargetSource targetSource = createBeanFactoryTargetSource(beanClass, beanName);
if (targetSource == null) {
return null;
}
if (log.isDebugEnabled()) {
log.debug("Configuring AbstractBeanFactoryBasedTargetSource: {}", targetSource);
}
StandardBeanFactory 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 = 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;
}
use of cn.taketoday.aop.target.AbstractBeanFactoryTargetSource in project today-infrastructure by TAKETODAY.
the class AbstractBeanFactoryTargetSourceCreator method getTargetSource.
// ---------------------------------------------------------------------
// Implementation of the TargetSourceCreator interface
// ---------------------------------------------------------------------
@Override
@Nullable
public final TargetSource getTargetSource(Class<?> beanClass, String beanName) {
AbstractBeanFactoryTargetSource targetSource = createBeanFactoryTargetSource(beanClass, beanName);
if (targetSource == null) {
return null;
}
if (log.isDebugEnabled()) {
log.debug("Configuring AbstractBeanFactoryBasedTargetSource: {}", targetSource);
}
StandardBeanFactory 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 = 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