AnnotationBeanNameGenerator (Spring Framework 7.0.8 API) JavaScript is disabled on your browser.     Skip navigation links Overview Class Use Tree Deprecated Index Search Help Spring Framework org.springframework.context.annotation AnnotationBeanNameGenerator Contents  Description Field Summary Constructor Summary Method Summary Field Details INSTANCE Constructor Details AnnotationBeanNameGenerator() Method Details generateBeanName(BeanDefinition, BeanDefinitionRegistry) determineBeanNameFromAnnotation(AnnotatedBeanDefinition) isStereotypeWithNameValue(String, Set, Map) buildDefaultBeanName(BeanDefinition, BeanDefinitionRegistry) buildDefaultBeanName(BeanDefinition) Hide sidebar  Show sidebar Class AnnotationBeanNameGenerator java.lang.Object org.springframework.context.annotation.AnnotationBeanNameGenerator All Implemented Interfaces: BeanNameGenerator Direct Known Subclasses: FullyQualifiedAnnotationBeanNameGenerator public class AnnotationBeanNameGenerator extends Object implements BeanNameGenerator BeanNameGenerator implementation for bean classes annotated with the @Component annotation or with another annotation that is itself annotated with @Component as a meta-annotation. For example, Spring's stereotype annotations (such as @Repository) are themselves annotated with @Component. Also supports JSR-330's Named annotation if available. Note that Spring component annotations always override such standard annotations. If the annotation's value doesn't indicate a bean name, an appropriate name will be built based on the short name of the class (with the first letter lower-cased), unless the first two letters are uppercase. For example: com.xyz.FooServiceImpl -> fooServiceImpl com.xyz.URLFooServiceImpl -> URLFooServiceImpl Since: 2.5 Author: Juergen Hoeller, Mark Fisher, Sam Brannen See Also: Component.value() Repository.value() Service.value() Controller.value() Named.value() FullyQualifiedAnnotationBeanNameGenerator Field Summary Fields Modifier and Type Field Description static final AnnotationBeanNameGenerator INSTANCE A convenient constant for a default AnnotationBeanNameGenerator instance, as used for component scanning purposes. Constructor Summary Constructors Constructor Description AnnotationBeanNameGenerator()   Method Summary All MethodsInstance MethodsConcrete Methods Modifier and Type Method Description protected String buildDefaultBeanName(BeanDefinition definition) Derive a default bean name from the given bean definition. protected String buildDefaultBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) Derive a default bean name from the given bean definition. protected @Nullable String determineBeanNameFromAnnotation(AnnotatedBeanDefinition annotatedDef) Derive a bean name from one of the annotations on the class. String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) Generate a bean name for the given bean definition. protected boolean isStereotypeWithNameValue(String annotationType, Set<String> metaAnnotationTypes, Map<String, @Nullable Object> attributes) Check whether the given annotation is a stereotype that is allowed to suggest a component name through its value() attribute. Methods inherited from class Object clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait Field Details INSTANCE public static final AnnotationBeanNameGenerator INSTANCE A convenient constant for a default AnnotationBeanNameGenerator instance, as used for component scanning purposes. Since: 5.2 Constructor Details AnnotationBeanNameGenerator public AnnotationBeanNameGenerator() Method Details generateBeanName public String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) Description copied from interface: BeanNameGenerator Generate a bean name for the given bean definition. Specified by: generateBeanName in interface BeanNameGenerator Parameters: definition - the bean definition to generate a name for registry - the bean definition registry that the given definition is supposed to be registered with Returns: the generated bean name determineBeanNameFromAnnotation protected @Nullable String determineBeanNameFromAnnotation(AnnotatedBeanDefinition annotatedDef) Derive a bean name from one of the annotations on the class. Parameters: annotatedDef - the annotation-aware bean definition Returns: the bean name, or null if none is found isStereotypeWithNameValue protected boolean isStereotypeWithNameValue(String annotationType, Set<String> metaAnnotationTypes, Map<String, @Nullable Object> attributes) Check whether the given annotation is a stereotype that is allowed to suggest a component name through its value() attribute. Parameters: annotationType - the name of the annotation class to check metaAnnotationTypes - the names of meta-annotations on the given annotation attributes - the map of attributes for the given annotation Returns: whether the annotation qualifies as a stereotype with component name buildDefaultBeanName protected String buildDefaultBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) Derive a default bean name from the given bean definition. The default implementation delegates to buildDefaultBeanName(BeanDefinition). Parameters: definition - the bean definition to build a bean name for registry - the registry that the given bean definition is being registered with Returns: the default bean name (never null) buildDefaultBeanName protected String buildDefaultBeanName(BeanDefinition definition) Derive a default bean name from the given bean definition. The default implementation simply builds a decapitalized version of the short class name: for example, "mypackage.MyJdbcDao" → "myJdbcDao". Note that inner classes will thus have names of the form "outerClassName.InnerClassName", which because of the period in the name may be an issue if you are autowiring by name. Parameters: definition - the bean definition to build a bean name for Returns: the default bean name (never null)