1
1
/*
2
- * Copyright 2002-2023 the original author or authors.
2
+ * Copyright 2002-2024 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -386,11 +386,11 @@ else if (ConfigurationClassUtils.checkConfigurationClassCandidate(beanDef, this.
386
386
});
387
387
388
388
// Detect any custom bean name generation strategy supplied through the enclosing application context
389
- SingletonBeanRegistry sbr = null ;
390
- if (registry instanceof SingletonBeanRegistry _sbr ) {
391
- sbr = _sbr ;
389
+ SingletonBeanRegistry singletonRegistry = null ;
390
+ if (registry instanceof SingletonBeanRegistry sbr ) {
391
+ singletonRegistry = sbr ;
392
392
if (!this .localBeanNameGeneratorSet ) {
393
- BeanNameGenerator generator = (BeanNameGenerator ) sbr .getSingleton (
393
+ BeanNameGenerator generator = (BeanNameGenerator ) singletonRegistry .getSingleton (
394
394
AnnotationConfigUtils .CONFIGURATION_BEAN_NAME_GENERATOR );
395
395
if (generator != null ) {
396
396
this .componentScanBeanNameGenerator = generator ;
@@ -451,8 +451,8 @@ else if (ConfigurationClassUtils.checkConfigurationClassCandidate(beanDef, this.
451
451
while (!candidates .isEmpty ());
452
452
453
453
// Register the ImportRegistry as a bean in order to support ImportAware @Configuration classes
454
- if (sbr != null && !sbr .containsSingleton (IMPORT_REGISTRY_BEAN_NAME )) {
455
- sbr .registerSingleton (IMPORT_REGISTRY_BEAN_NAME , parser .getImportRegistry ());
454
+ if (singletonRegistry != null && !singletonRegistry .containsSingleton (IMPORT_REGISTRY_BEAN_NAME )) {
455
+ singletonRegistry .registerSingleton (IMPORT_REGISTRY_BEAN_NAME , parser .getImportRegistry ());
456
456
}
457
457
458
458
// Store the PropertySourceDescriptors to contribute them Ahead-of-time if necessary
@@ -550,6 +550,7 @@ public ImportAwareBeanPostProcessor(BeanFactory beanFactory) {
550
550
}
551
551
552
552
@ Override
553
+ @ Nullable
553
554
public PropertyValues postProcessProperties (@ Nullable PropertyValues pvs , Object bean , String beanName ) {
554
555
// Inject the BeanFactory before AutowiredAnnotationBeanPostProcessor's
555
556
// postProcessProperties method attempts to autowire other configuration beans.
@@ -645,9 +646,9 @@ private Map<String, String> buildImportAwareMappings() {
645
646
}
646
647
return mappings ;
647
648
}
648
-
649
649
}
650
650
651
+
651
652
private static class PropertySourcesAotContribution implements BeanFactoryInitializationAotContribution {
652
653
653
654
private static final String ENVIRONMENT_VARIABLE = "environment" ;
@@ -743,22 +744,22 @@ private CodeBlock handleNull(@Nullable Object value, Supplier<CodeBlock> nonNull
743
744
return nonNull .get ();
744
745
}
745
746
}
746
-
747
747
}
748
748
749
+
749
750
private static class ConfigurationClassProxyBeanRegistrationCodeFragments extends BeanRegistrationCodeFragmentsDecorator {
750
751
751
752
private final Class <?> proxyClass ;
752
753
753
- public ConfigurationClassProxyBeanRegistrationCodeFragments (BeanRegistrationCodeFragments codeFragments ,
754
- Class <?> proxyClass ) {
754
+ public ConfigurationClassProxyBeanRegistrationCodeFragments (BeanRegistrationCodeFragments codeFragments , Class <?> proxyClass ) {
755
755
super (codeFragments );
756
756
this .proxyClass = proxyClass ;
757
757
}
758
758
759
759
@ Override
760
760
public CodeBlock generateSetBeanDefinitionPropertiesCode (GenerationContext generationContext ,
761
761
BeanRegistrationCode beanRegistrationCode , RootBeanDefinition beanDefinition , Predicate <String > attributeFilter ) {
762
+
762
763
CodeBlock .Builder code = CodeBlock .builder ();
763
764
code .add (super .generateSetBeanDefinitionPropertiesCode (generationContext ,
764
765
beanRegistrationCode , beanDefinition , attributeFilter ));
@@ -771,6 +772,7 @@ public CodeBlock generateSetBeanDefinitionPropertiesCode(GenerationContext gener
771
772
public CodeBlock generateInstanceSupplierCode (GenerationContext generationContext ,
772
773
BeanRegistrationCode beanRegistrationCode , Executable constructorOrFactoryMethod ,
773
774
boolean allowDirectSupplierShortcut ) {
775
+
774
776
Executable executableToUse = proxyExecutable (generationContext .getRuntimeHints (), constructorOrFactoryMethod );
775
777
return super .generateInstanceSupplierCode (generationContext , beanRegistrationCode ,
776
778
executableToUse , allowDirectSupplierShortcut );
@@ -788,7 +790,6 @@ private Executable proxyExecutable(RuntimeHints runtimeHints, Executable userExe
788
790
}
789
791
return userExecutable ;
790
792
}
791
-
792
793
}
793
794
794
795
}
0 commit comments