@Autowired-driven ObjectFactory/Provider resolution works in non-singleton beans as well
Issue: SPR-9181
This commit is contained in:
@@ -121,6 +121,24 @@ public class DependencyDescriptor implements Serializable {
|
||||
this.eager = eager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
* @param original the original descriptor to create a copy from
|
||||
*/
|
||||
public DependencyDescriptor(DependencyDescriptor original) {
|
||||
this.methodParameter = original.methodParameter;
|
||||
this.field = original.field;
|
||||
this.declaringClass = original.declaringClass;
|
||||
this.methodName = original.methodName;
|
||||
this.parameterTypes = original.parameterTypes;
|
||||
this.parameterIndex = original.parameterIndex;
|
||||
this.fieldName = original.fieldName;
|
||||
this.required = original.required;
|
||||
this.eager = original.eager;
|
||||
this.nestingLevel = original.nestingLevel;
|
||||
this.fieldAnnotations = original.fieldAnnotations;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the wrapped MethodParameter, if any.
|
||||
@@ -156,6 +174,10 @@ public class DependencyDescriptor implements Serializable {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Increase this descriptor's nesting level.
|
||||
* @see MethodParameter#increaseNestingLevel()
|
||||
*/
|
||||
public void increaseNestingLevel() {
|
||||
this.nestingLevel++;
|
||||
if (this.methodParameter != null) {
|
||||
|
||||
@@ -21,14 +21,11 @@ import java.io.NotSerializableException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@@ -39,7 +36,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.inject.Provider;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
@@ -1031,9 +1027,9 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
private final String beanName;
|
||||
|
||||
public DependencyObjectFactory(DependencyDescriptor descriptor, String beanName) {
|
||||
this.descriptor = descriptor;
|
||||
this.beanName = beanName;
|
||||
this.descriptor = new DependencyDescriptor(descriptor);
|
||||
this.descriptor.increaseNestingLevel();
|
||||
this.beanName = beanName;
|
||||
}
|
||||
|
||||
public Object getObject() throws BeansException {
|
||||
|
||||
Reference in New Issue
Block a user