Class FullyQualifiedConfigurationBeanNameGenerator

All Implemented Interfaces:
BeanNameGenerator, ConfigurationBeanNameGenerator

public class FullyQualifiedConfigurationBeanNameGenerator extends FullyQualifiedAnnotationBeanNameGenerator implements ConfigurationBeanNameGenerator
Extended variant of FullyQualifiedAnnotationBeanNameGenerator for @Configuration class purposes, not only enforcing fully-qualified names for component and configuration classes themselves but also fully-qualified default bean names ("className.methodName") for @Bean methods. By default, this only affects methods without an explicit name attribute specified.

This provides an alternative to the default bean name generation for @Bean methods (which uses the plain method name), primarily for use in large applications with potential bean name overlaps. Favor this bean naming strategy over FullyQualifiedAnnotationBeanNameGenerator if you expect such naming conflicts for @Bean methods.

As of 7.1, the original @Bean method name will be registered as an alias if that name has not been taken already: effectively on first occurrence, whereas any later @Bean methods of the same name will not have aliases applied. This preserves the availability of common beans under the original bean names for retrieval and injection purposes.

Since:
7.0
Author:
Juergen Hoeller
See Also:
  • Field Details

    • INSTANCE

      public static final FullyQualifiedConfigurationBeanNameGenerator INSTANCE
      A convenient constant for a default FullyQualifiedConfigurationBeanNameGenerator instance, as used for configuration-level import purposes.
  • Constructor Details

    • FullyQualifiedConfigurationBeanNameGenerator

      public FullyQualifiedConfigurationBeanNameGenerator()
  • Method Details

    • deriveBeanName

      public String deriveBeanName(MethodMetadata beanMethod, @Nullable String beanName)
      Description copied from interface: ConfigurationBeanNameGenerator
      Derive a default bean name for the given @Bean method, taking into account the specified name attribute.

      As of 7.1, the original @Bean name (typically the method name) will be registered as an alias if that name has not been taken already.

      Specified by:
      deriveBeanName in interface ConfigurationBeanNameGenerator
      Parameters:
      beanMethod - the method metadata for the @Bean method
      beanName - the name attribute or null if none is specified
      Returns:
      the default bean name to use