Polishing
This commit is contained in:
@@ -252,7 +252,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
throw new BeanCreationException(beanName,
|
||||
"Cannot apply @Lookup to beans without corresponding bean definition");
|
||||
"Cannot apply @Lookup to beans without corresponding bean definition");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -107,8 +107,8 @@ class ConstructorResolver {
|
||||
* or {@code null} if none (-> use constructor argument values from bean definition)
|
||||
* @return a BeanWrapper for the new instance
|
||||
*/
|
||||
public BeanWrapper autowireConstructor(final String beanName, final RootBeanDefinition mbd,
|
||||
@Nullable Constructor<?>[] chosenCtors, @Nullable final Object[] explicitArgs) {
|
||||
public BeanWrapper autowireConstructor(String beanName, RootBeanDefinition mbd,
|
||||
@Nullable Constructor<?>[] chosenCtors, @Nullable Object[] explicitArgs) {
|
||||
|
||||
BeanWrapperImpl bw = new BeanWrapperImpl();
|
||||
this.beanFactory.initBeanWrapper(bw);
|
||||
@@ -326,7 +326,7 @@ class ConstructorResolver {
|
||||
* the {@link RootBeanDefinition#isNonPublicAccessAllowed()} flag.
|
||||
* Called as the starting point for factory method determination.
|
||||
*/
|
||||
private Method[] getCandidateMethods(final Class<?> factoryClass, final RootBeanDefinition mbd) {
|
||||
private Method[] getCandidateMethods(Class<?> factoryClass, RootBeanDefinition mbd) {
|
||||
if (System.getSecurityManager() != null) {
|
||||
return AccessController.doPrivileged((PrivilegedAction<Method[]>) () ->
|
||||
(mbd.isNonPublicAccessAllowed() ?
|
||||
@@ -354,7 +354,7 @@ class ConstructorResolver {
|
||||
* @return a BeanWrapper for the new instance
|
||||
*/
|
||||
public BeanWrapper instantiateUsingFactoryMethod(
|
||||
final String beanName, final RootBeanDefinition mbd, @Nullable final Object[] explicitArgs) {
|
||||
String beanName, RootBeanDefinition mbd, @Nullable Object[] explicitArgs) {
|
||||
|
||||
BeanWrapperImpl bw = new BeanWrapperImpl();
|
||||
this.beanFactory.initBeanWrapper(bw);
|
||||
@@ -417,13 +417,13 @@ class ConstructorResolver {
|
||||
factoryClass = ClassUtils.getUserClass(factoryClass);
|
||||
|
||||
Method[] rawCandidates = getCandidateMethods(factoryClass, mbd);
|
||||
List<Method> candidateSet = new ArrayList<>();
|
||||
List<Method> candidateList = new ArrayList<>();
|
||||
for (Method candidate : rawCandidates) {
|
||||
if (Modifier.isStatic(candidate.getModifiers()) == isStatic && mbd.isFactoryMethod(candidate)) {
|
||||
candidateSet.add(candidate);
|
||||
candidateList.add(candidate);
|
||||
}
|
||||
}
|
||||
Method[] candidates = candidateSet.toArray(new Method[0]);
|
||||
Method[] candidates = candidateList.toArray(new Method[0]);
|
||||
AutowireUtils.sortFactoryMethods(candidates);
|
||||
|
||||
ConstructorArgumentValues resolvedValues = null;
|
||||
@@ -456,7 +456,7 @@ class ConstructorResolver {
|
||||
if (paramTypes.length >= minNrOfArgs) {
|
||||
ArgumentsHolder argsHolder;
|
||||
|
||||
if (explicitArgs != null){
|
||||
if (explicitArgs != null) {
|
||||
// Explicit arguments given -> arguments length must match exactly.
|
||||
if (paramTypes.length != explicitArgs.length) {
|
||||
continue;
|
||||
@@ -529,7 +529,7 @@ class ConstructorResolver {
|
||||
argTypes.add(arg != null ? arg.getClass().getSimpleName() : "null");
|
||||
}
|
||||
}
|
||||
else if (resolvedValues != null){
|
||||
else if (resolvedValues != null) {
|
||||
Set<ValueHolder> valueHolders = new LinkedHashSet<>(resolvedValues.getArgumentCount());
|
||||
valueHolders.addAll(resolvedValues.getIndexedArgumentValues().values());
|
||||
valueHolders.addAll(resolvedValues.getGenericArgumentValues());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,8 +38,8 @@ public interface InstantiationStrategy {
|
||||
/**
|
||||
* Return an instance of the bean with the given name in this factory.
|
||||
* @param bd the bean definition
|
||||
* @param beanName the name of the bean when it's created in this context.
|
||||
* The name can be {@code null} if we're autowiring a bean which doesn't
|
||||
* @param beanName the name of the bean when it is created in this context.
|
||||
* The name can be {@code null} if we are autowiring a bean which doesn't
|
||||
* belong to the factory.
|
||||
* @param owner the owning BeanFactory
|
||||
* @return a bean instance for this bean definition
|
||||
@@ -52,8 +52,8 @@ public interface InstantiationStrategy {
|
||||
* Return an instance of the bean with the given name in this factory,
|
||||
* creating it via the given constructor.
|
||||
* @param bd the bean definition
|
||||
* @param beanName the name of the bean when it's created in this context.
|
||||
* The name can be {@code null} if we're autowiring a bean which doesn't
|
||||
* @param beanName the name of the bean when it is created in this context.
|
||||
* The name can be {@code null} if we are autowiring a bean which doesn't
|
||||
* belong to the factory.
|
||||
* @param owner the owning BeanFactory
|
||||
* @param ctor the constructor to use
|
||||
@@ -68,8 +68,8 @@ public interface InstantiationStrategy {
|
||||
* Return an instance of the bean with the given name in this factory,
|
||||
* creating it via the given factory method.
|
||||
* @param bd the bean definition
|
||||
* @param beanName the name of the bean when it's created in this context.
|
||||
* The name can be {@code null} if we're autowiring a bean which doesn't
|
||||
* @param beanName the name of the bean when it is created in this context.
|
||||
* The name can be {@code null} if we are autowiring a bean which doesn't
|
||||
* belong to the factory.
|
||||
* @param owner the owning BeanFactory
|
||||
* @param factoryBean the factory bean instance to call the factory method on,
|
||||
|
||||
Reference in New Issue
Block a user