|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2019 the original author or authors. |
|
|
|
* Copyright 2002-2020 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -294,7 +294,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac |
|
|
|
public void autowireBean(Object existingBean) { |
|
|
|
public void autowireBean(Object existingBean) { |
|
|
|
// Use non-singleton bean definition, to avoid registering bean as dependent bean.
|
|
|
|
// Use non-singleton bean definition, to avoid registering bean as dependent bean.
|
|
|
|
RootBeanDefinition bd = new RootBeanDefinition(ClassUtils.getUserClass(existingBean)); |
|
|
|
RootBeanDefinition bd = new RootBeanDefinition(ClassUtils.getUserClass(existingBean)); |
|
|
|
bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); |
|
|
|
bd.setScope(SCOPE_PROTOTYPE); |
|
|
|
bd.allowCaching = ClassUtils.isCacheSafe(bd.getBeanClass(), getBeanClassLoader()); |
|
|
|
bd.allowCaching = ClassUtils.isCacheSafe(bd.getBeanClass(), getBeanClassLoader()); |
|
|
|
BeanWrapper bw = new BeanWrapperImpl(existingBean); |
|
|
|
BeanWrapper bw = new BeanWrapperImpl(existingBean); |
|
|
|
initBeanWrapper(bw); |
|
|
|
initBeanWrapper(bw); |
|
|
|
@ -314,7 +314,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac |
|
|
|
if (bd == null) { |
|
|
|
if (bd == null) { |
|
|
|
bd = new RootBeanDefinition(mbd); |
|
|
|
bd = new RootBeanDefinition(mbd); |
|
|
|
} |
|
|
|
} |
|
|
|
bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); |
|
|
|
bd.setScope(SCOPE_PROTOTYPE); |
|
|
|
bd.allowCaching = ClassUtils.isCacheSafe(ClassUtils.getUserClass(existingBean), getBeanClassLoader()); |
|
|
|
bd.allowCaching = ClassUtils.isCacheSafe(ClassUtils.getUserClass(existingBean), getBeanClassLoader()); |
|
|
|
} |
|
|
|
} |
|
|
|
BeanWrapper bw = new BeanWrapperImpl(existingBean); |
|
|
|
BeanWrapper bw = new BeanWrapperImpl(existingBean); |
|
|
|
@ -337,7 +337,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac |
|
|
|
public Object createBean(Class<?> beanClass, int autowireMode, boolean dependencyCheck) throws BeansException { |
|
|
|
public Object createBean(Class<?> beanClass, int autowireMode, boolean dependencyCheck) throws BeansException { |
|
|
|
// Use non-singleton bean definition, to avoid registering bean as dependent bean.
|
|
|
|
// Use non-singleton bean definition, to avoid registering bean as dependent bean.
|
|
|
|
RootBeanDefinition bd = new RootBeanDefinition(beanClass, autowireMode, dependencyCheck); |
|
|
|
RootBeanDefinition bd = new RootBeanDefinition(beanClass, autowireMode, dependencyCheck); |
|
|
|
bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); |
|
|
|
bd.setScope(SCOPE_PROTOTYPE); |
|
|
|
return createBean(beanClass.getName(), bd, null); |
|
|
|
return createBean(beanClass.getName(), bd, null); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -345,7 +345,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac |
|
|
|
public Object autowire(Class<?> beanClass, int autowireMode, boolean dependencyCheck) throws BeansException { |
|
|
|
public Object autowire(Class<?> beanClass, int autowireMode, boolean dependencyCheck) throws BeansException { |
|
|
|
// Use non-singleton bean definition, to avoid registering bean as dependent bean.
|
|
|
|
// Use non-singleton bean definition, to avoid registering bean as dependent bean.
|
|
|
|
final RootBeanDefinition bd = new RootBeanDefinition(beanClass, autowireMode, dependencyCheck); |
|
|
|
final RootBeanDefinition bd = new RootBeanDefinition(beanClass, autowireMode, dependencyCheck); |
|
|
|
bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); |
|
|
|
bd.setScope(SCOPE_PROTOTYPE); |
|
|
|
if (bd.getResolvedAutowireMode() == AUTOWIRE_CONSTRUCTOR) { |
|
|
|
if (bd.getResolvedAutowireMode() == AUTOWIRE_CONSTRUCTOR) { |
|
|
|
return autowireConstructor(beanClass.getName(), bd, null, null).getWrappedInstance(); |
|
|
|
return autowireConstructor(beanClass.getName(), bd, null, null).getWrappedInstance(); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -378,7 +378,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac |
|
|
|
// Use non-singleton bean definition, to avoid registering bean as dependent bean.
|
|
|
|
// Use non-singleton bean definition, to avoid registering bean as dependent bean.
|
|
|
|
RootBeanDefinition bd = |
|
|
|
RootBeanDefinition bd = |
|
|
|
new RootBeanDefinition(ClassUtils.getUserClass(existingBean), autowireMode, dependencyCheck); |
|
|
|
new RootBeanDefinition(ClassUtils.getUserClass(existingBean), autowireMode, dependencyCheck); |
|
|
|
bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); |
|
|
|
bd.setScope(SCOPE_PROTOTYPE); |
|
|
|
BeanWrapper bw = new BeanWrapperImpl(existingBean); |
|
|
|
BeanWrapper bw = new BeanWrapperImpl(existingBean); |
|
|
|
initBeanWrapper(bw); |
|
|
|
initBeanWrapper(bw); |
|
|
|
populateBean(bd.getBeanClass().getName(), bd, bw); |
|
|
|
populateBean(bd.getBeanClass().getName(), bd, bw); |
|
|
|
@ -584,7 +584,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac |
|
|
|
"] in its raw version as part of a circular reference, but has eventually been " + |
|
|
|
"] in its raw version as part of a circular reference, but has eventually been " + |
|
|
|
"wrapped. This means that said other beans do not use the final version of the " + |
|
|
|
"wrapped. This means that said other beans do not use the final version of the " + |
|
|
|
"bean. This is often the result of over-eager type matching - consider using " + |
|
|
|
"bean. This is often the result of over-eager type matching - consider using " + |
|
|
|
"'getBeanNamesOfType' with the 'allowEagerInit' flag turned off, for example."); |
|
|
|
"'getBeanNamesForType' with the 'allowEagerInit' flag turned off, for example."); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|