|
|
@ -453,27 +453,27 @@ class ConstructorResolver { |
|
|
|
// Try all methods with this name to see if they match the given arguments.
|
|
|
|
// Try all methods with this name to see if they match the given arguments.
|
|
|
|
factoryClass = ClassUtils.getUserClass(factoryClass); |
|
|
|
factoryClass = ClassUtils.getUserClass(factoryClass); |
|
|
|
|
|
|
|
|
|
|
|
List<Method> candidateList = null; |
|
|
|
List<Method> candidates = null; |
|
|
|
if (mbd.isFactoryMethodUnique) { |
|
|
|
if (mbd.isFactoryMethodUnique) { |
|
|
|
if (factoryMethodToUse == null) { |
|
|
|
if (factoryMethodToUse == null) { |
|
|
|
factoryMethodToUse = mbd.getResolvedFactoryMethod(); |
|
|
|
factoryMethodToUse = mbd.getResolvedFactoryMethod(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (factoryMethodToUse != null) { |
|
|
|
if (factoryMethodToUse != null) { |
|
|
|
candidateList = Collections.singletonList(factoryMethodToUse); |
|
|
|
candidates = Collections.singletonList(factoryMethodToUse); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (candidateList == null) { |
|
|
|
if (candidates == null) { |
|
|
|
candidateList = new ArrayList<>(); |
|
|
|
candidates = new ArrayList<>(); |
|
|
|
Method[] rawCandidates = getCandidateMethods(factoryClass, mbd); |
|
|
|
Method[] rawCandidates = getCandidateMethods(factoryClass, mbd); |
|
|
|
for (Method candidate : rawCandidates) { |
|
|
|
for (Method candidate : rawCandidates) { |
|
|
|
if (Modifier.isStatic(candidate.getModifiers()) == isStatic && mbd.isFactoryMethod(candidate)) { |
|
|
|
if (Modifier.isStatic(candidate.getModifiers()) == isStatic && mbd.isFactoryMethod(candidate)) { |
|
|
|
candidateList.add(candidate); |
|
|
|
candidates.add(candidate); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (candidateList.size() == 1 && explicitArgs == null && !mbd.hasConstructorArgumentValues()) { |
|
|
|
if (candidates.size() == 1 && explicitArgs == null && !mbd.hasConstructorArgumentValues()) { |
|
|
|
Method uniqueCandidate = candidateList.get(0); |
|
|
|
Method uniqueCandidate = candidates.get(0); |
|
|
|
if (uniqueCandidate.getParameterCount() == 0) { |
|
|
|
if (uniqueCandidate.getParameterCount() == 0) { |
|
|
|
mbd.factoryMethodToIntrospect = uniqueCandidate; |
|
|
|
mbd.factoryMethodToIntrospect = uniqueCandidate; |
|
|
|
synchronized (mbd.constructorArgumentLock) { |
|
|
|
synchronized (mbd.constructorArgumentLock) { |
|
|
@ -486,8 +486,7 @@ class ConstructorResolver { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Method[] candidates = candidateList.toArray(new Method[0]); |
|
|
|
candidates.sort(AutowireUtils.EXECUTABLE_COMPARATOR); |
|
|
|
AutowireUtils.sortFactoryMethods(candidates); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ConstructorArgumentValues resolvedValues = null; |
|
|
|
ConstructorArgumentValues resolvedValues = null; |
|
|
|
boolean autowiring = (mbd.getResolvedAutowireMode() == AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR); |
|
|
|
boolean autowiring = (mbd.getResolvedAutowireMode() == AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR); |
|
|
@ -536,7 +535,7 @@ class ConstructorResolver { |
|
|
|
paramNames = pnd.getParameterNames(candidate); |
|
|
|
paramNames = pnd.getParameterNames(candidate); |
|
|
|
} |
|
|
|
} |
|
|
|
argsHolder = createArgumentArray(beanName, mbd, resolvedValues, bw, |
|
|
|
argsHolder = createArgumentArray(beanName, mbd, resolvedValues, bw, |
|
|
|
paramTypes, paramNames, candidate, autowiring, candidates.length == 1); |
|
|
|
paramTypes, paramNames, candidate, autowiring, candidates.size() == 1); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (UnsatisfiedDependencyException ex) { |
|
|
|
catch (UnsatisfiedDependencyException ex) { |
|
|
|
if (logger.isTraceEnabled()) { |
|
|
|
if (logger.isTraceEnabled()) { |
|
|
|