|
86 | 86 | public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPostProcessor,
|
87 | 87 | PriorityOrdered, ResourceLoaderAware, BeanClassLoaderAware, EnvironmentAware {
|
88 | 88 |
|
| 89 | + /** |
| 90 | + * A {@code BeanNameGenerator} using fully qualified class names as default bean names. |
| 91 | + * <p>This default for configuration-level import purposes may be overridden through |
| 92 | + * {@link #setBeanNameGenerator}. Note that the default for component scanning purposes |
| 93 | + * is a plain {@link AnnotationBeanNameGenerator#INSTANCE}, unless overridden through |
| 94 | + * {@link #setBeanNameGenerator} with a unified user-level bean name generator. |
| 95 | + * @since 5.2 |
| 96 | + * @see #setBeanNameGenerator |
| 97 | + */ |
| 98 | + public static final AnnotationBeanNameGenerator IMPORT_BEAN_NAME_GENERATOR = new AnnotationBeanNameGenerator() { |
| 99 | + @Override |
| 100 | + protected String buildDefaultBeanName(BeanDefinition definition) { |
| 101 | + String beanClassName = definition.getBeanClassName(); |
| 102 | + Assert.state(beanClassName != null, "No bean class name set"); |
| 103 | + return beanClassName; |
| 104 | + } |
| 105 | + }; |
| 106 | + |
89 | 107 | private static final String IMPORT_REGISTRY_BEAN_NAME =
|
90 | 108 | ConfigurationClassPostProcessor.class.getName() + ".importRegistry";
|
91 | 109 |
|
@@ -117,18 +135,11 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo
|
117 | 135 |
|
118 | 136 | private boolean localBeanNameGeneratorSet = false;
|
119 | 137 |
|
120 |
| - /* Using short class names as default bean names */ |
121 |
| - private BeanNameGenerator componentScanBeanNameGenerator = new AnnotationBeanNameGenerator(); |
| 138 | + /* Using short class names as default bean names by default. */ |
| 139 | + private BeanNameGenerator componentScanBeanNameGenerator = AnnotationBeanNameGenerator.INSTANCE; |
122 | 140 |
|
123 |
| - /* Using fully qualified class names as default bean names */ |
124 |
| - private BeanNameGenerator importBeanNameGenerator = new AnnotationBeanNameGenerator() { |
125 |
| - @Override |
126 |
| - protected String buildDefaultBeanName(BeanDefinition definition) { |
127 |
| - String beanClassName = definition.getBeanClassName(); |
128 |
| - Assert.state(beanClassName != null, "No bean class name set"); |
129 |
| - return beanClassName; |
130 |
| - } |
131 |
| - }; |
| 141 | + /* Using fully qualified class names as default bean names by default. */ |
| 142 | + private BeanNameGenerator importBeanNameGenerator = IMPORT_BEAN_NAME_GENERATOR; |
132 | 143 |
|
133 | 144 |
|
134 | 145 | @Override
|
|
0 commit comments