@@ -294,12 +294,12 @@ public Comparator<Object> getDependencyComparator() {
294
294
* when deciding whether a bean definition should be considered as a
295
295
* candidate for autowiring.
296
296
*/
297
- public void setAutowireCandidateResolver (final AutowireCandidateResolver autowireCandidateResolver ) {
297
+ public void setAutowireCandidateResolver (AutowireCandidateResolver autowireCandidateResolver ) {
298
298
Assert .notNull (autowireCandidateResolver , "AutowireCandidateResolver must not be null" );
299
299
if (autowireCandidateResolver instanceof BeanFactoryAware ) {
300
300
if (System .getSecurityManager () != null ) {
301
301
AccessController .doPrivileged ((PrivilegedAction <Object >) () -> {
302
- ((BeanFactoryAware ) autowireCandidateResolver ).setBeanFactory (DefaultListableBeanFactory . this );
302
+ ((BeanFactoryAware ) autowireCandidateResolver ).setBeanFactory (this );
303
303
return null ;
304
304
}, getAccessControlContext ());
305
305
}
@@ -512,8 +512,7 @@ private String[] doGetBeanNamesForType(ResolvableType type, boolean includeNonSi
512
512
513
513
// Check all bean definitions.
514
514
for (String beanName : this .beanDefinitionNames ) {
515
- // Only consider bean as eligible if the bean name
516
- // is not defined as alias for some other bean.
515
+ // Only consider bean as eligible if the bean name is not defined as alias for some other bean.
517
516
if (!isAlias (beanName )) {
518
517
try {
519
518
RootBeanDefinition mbd = getMergedLocalBeanDefinition (beanName );
@@ -524,8 +523,8 @@ private String[] doGetBeanNamesForType(ResolvableType type, boolean includeNonSi
524
523
boolean isFactoryBean = isFactoryBean (beanName , mbd );
525
524
BeanDefinitionHolder dbd = mbd .getDecoratedDefinition ();
526
525
boolean matchFound = false ;
527
- boolean allowFactoryBeanInit = allowEagerInit || containsSingleton (beanName );
528
- boolean isNonLazyDecorated = dbd != null && !mbd .isLazyInit ();
526
+ boolean allowFactoryBeanInit = ( allowEagerInit || containsSingleton (beanName ) );
527
+ boolean isNonLazyDecorated = ( dbd != null && !mbd .isLazyInit () );
529
528
if (!isFactoryBean ) {
530
529
if (includeNonSingletons || isSingleton (beanName , mbd , dbd )) {
531
530
matchFound = isTypeMatch (beanName , type , allowFactoryBeanInit );
@@ -552,9 +551,9 @@ private String[] doGetBeanNamesForType(ResolvableType type, boolean includeNonSi
552
551
throw ex ;
553
552
}
554
553
// Probably a placeholder: let's ignore it for type matching purposes.
555
- LogMessage message = (ex instanceof CannotLoadBeanClassException ) ?
554
+ LogMessage message = (ex instanceof CannotLoadBeanClassException ?
556
555
LogMessage .format ("Ignoring bean class loading failure for bean '%s'" , beanName ) :
557
- LogMessage .format ("Ignoring unresolvable metadata in bean definition '%s'" , beanName );
556
+ LogMessage .format ("Ignoring unresolvable metadata in bean definition '%s'" , beanName )) ;
558
557
logger .trace (message , ex );
559
558
onSuppressedException (ex );
560
559
}
@@ -582,7 +581,8 @@ private String[] doGetBeanNamesForType(ResolvableType type, boolean includeNonSi
582
581
}
583
582
catch (NoSuchBeanDefinitionException ex ) {
584
583
// Shouldn't happen - probably a result of circular reference resolution...
585
- logger .trace (LogMessage .format ("Failed to check manually registered singleton with name '%s'" , beanName ), ex );
584
+ logger .trace (LogMessage .format (
585
+ "Failed to check manually registered singleton with name '%s'" , beanName ), ex );
586
586
}
587
587
}
588
588
@@ -611,8 +611,8 @@ public <T> Map<String, T> getBeansOfType(@Nullable Class<T> type) throws BeansEx
611
611
612
612
@ Override
613
613
@ SuppressWarnings ("unchecked" )
614
- public <T > Map <String , T > getBeansOfType (@ Nullable Class < T > type , boolean includeNonSingletons , boolean allowEagerInit )
615
- throws BeansException {
614
+ public <T > Map <String , T > getBeansOfType (
615
+ @ Nullable Class < T > type , boolean includeNonSingletons , boolean allowEagerInit ) throws BeansException {
616
616
617
617
String [] beanNames = getBeanNamesForType (type , includeNonSingletons , allowEagerInit );
618
618
Map <String , T > result = new LinkedHashMap <>(beanNames .length );
@@ -753,12 +753,13 @@ public boolean isAutowireCandidate(String beanName, DependencyDescriptor descrip
753
753
* @param resolver the AutowireCandidateResolver to use for the actual resolution algorithm
754
754
* @return whether the bean should be considered as autowire candidate
755
755
*/
756
- protected boolean isAutowireCandidate (String beanName , DependencyDescriptor descriptor , AutowireCandidateResolver resolver )
756
+ protected boolean isAutowireCandidate (
757
+ String beanName , DependencyDescriptor descriptor , AutowireCandidateResolver resolver )
757
758
throws NoSuchBeanDefinitionException {
758
759
759
- String beanDefinitionName = BeanFactoryUtils .transformedBeanName (beanName );
760
- if (containsBeanDefinition (beanDefinitionName )) {
761
- return isAutowireCandidate (beanName , getMergedLocalBeanDefinition (beanDefinitionName ), descriptor , resolver );
760
+ String bdName = BeanFactoryUtils .transformedBeanName (beanName );
761
+ if (containsBeanDefinition (bdName )) {
762
+ return isAutowireCandidate (beanName , getMergedLocalBeanDefinition (bdName ), descriptor , resolver );
762
763
}
763
764
else if (containsSingleton (beanName )) {
764
765
return isAutowireCandidate (beanName , new RootBeanDefinition (getType (beanName )), descriptor , resolver );
@@ -790,15 +791,15 @@ else if (parent instanceof ConfigurableListableBeanFactory) {
790
791
protected boolean isAutowireCandidate (String beanName , RootBeanDefinition mbd ,
791
792
DependencyDescriptor descriptor , AutowireCandidateResolver resolver ) {
792
793
793
- String beanDefinitionName = BeanFactoryUtils .transformedBeanName (beanName );
794
- resolveBeanClass (mbd , beanDefinitionName );
794
+ String bdName = BeanFactoryUtils .transformedBeanName (beanName );
795
+ resolveBeanClass (mbd , bdName );
795
796
if (mbd .isFactoryMethodUnique && mbd .factoryMethodToIntrospect == null ) {
796
797
new ConstructorResolver (this ).resolveFactoryMethodIfPossible (mbd );
797
798
}
798
- BeanDefinitionHolder holder = (beanName .equals (beanDefinitionName ) ?
799
+ BeanDefinitionHolder holder = (beanName .equals (bdName ) ?
799
800
this .mergedBeanDefinitionHolders .computeIfAbsent (beanName ,
800
- key -> new BeanDefinitionHolder (mbd , beanName , getAliases (beanDefinitionName ))) :
801
- new BeanDefinitionHolder (mbd , beanName , getAliases (beanDefinitionName )));
801
+ key -> new BeanDefinitionHolder (mbd , beanName , getAliases (bdName ))) :
802
+ new BeanDefinitionHolder (mbd , beanName , getAliases (bdName )));
802
803
return resolver .isAutowireCandidate (holder , descriptor );
803
804
}
804
805
@@ -873,11 +874,11 @@ public void preInstantiateSingletons() throws BeansException {
873
874
if (isFactoryBean (beanName )) {
874
875
Object bean = getBean (FACTORY_BEAN_PREFIX + beanName );
875
876
if (bean instanceof FactoryBean ) {
876
- final FactoryBean <?> factory = (FactoryBean <?>) bean ;
877
+ FactoryBean <?> factory = (FactoryBean <?>) bean ;
877
878
boolean isEagerInit ;
878
879
if (System .getSecurityManager () != null && factory instanceof SmartFactoryBean ) {
879
- isEagerInit = AccessController .doPrivileged (( PrivilegedAction < Boolean >)
880
- ((SmartFactoryBean <?>) factory )::isEagerInit ,
880
+ isEagerInit = AccessController .doPrivileged (
881
+ ( PrivilegedAction < Boolean >) ((SmartFactoryBean <?>) factory )::isEagerInit ,
881
882
getAccessControlContext ());
882
883
}
883
884
else {
@@ -899,7 +900,7 @@ public void preInstantiateSingletons() throws BeansException {
899
900
for (String beanName : beanNames ) {
900
901
Object singletonInstance = getSingleton (beanName );
901
902
if (singletonInstance instanceof SmartInitializingSingleton ) {
902
- final SmartInitializingSingleton smartSingleton = (SmartInitializingSingleton ) singletonInstance ;
903
+ SmartInitializingSingleton smartSingleton = (SmartInitializingSingleton ) singletonInstance ;
903
904
if (System .getSecurityManager () != null ) {
904
905
AccessController .doPrivileged ((PrivilegedAction <Object >) () -> {
905
906
smartSingleton .afterSingletonsInstantiated ();
@@ -1324,7 +1325,7 @@ public Object doResolveDependency(DependencyDescriptor descriptor, @Nullable Str
1324
1325
private Object resolveMultipleBeans (DependencyDescriptor descriptor , @ Nullable String beanName ,
1325
1326
@ Nullable Set <String > autowiredBeanNames , @ Nullable TypeConverter typeConverter ) {
1326
1327
1327
- final Class <?> type = descriptor .getDependencyType ();
1328
+ Class <?> type = descriptor .getDependencyType ();
1328
1329
1329
1330
if (descriptor instanceof StreamDependencyDescriptor ) {
1330
1331
Map <String , Object > matchingBeans = findAutowireCandidates (beanName , type , descriptor );
0 commit comments