类 AnnotationBeanNameGenerator
- 所有已实现的接口:
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, Framework's stereotype annotations (such as
@Repository) are
themselves annotated with @Component.
Also supports Jakarta EE's ManagedBean and
JSR-330's Named annotations, if available. Note that
Framework 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 two first letters are uppercase. For example:
com.xyz.FooServiceImpl -> fooServiceImpl
com.xyz.URLFooServiceImpl -> URLFooServiceImpl
- 从以下版本开始:
- 4.0
- 作者:
- Juergen Hoeller, Mark Fisher, Harry Yang
- 另请参阅:
-
字段概要
字段修饰符和类型字段说明static final AnnotationBeanNameGeneratorA convenient constant for a defaultAnnotationBeanNameGeneratorinstance, as used for component scanning purposes. -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明protected StringbuildDefaultBeanName(BeanDefinition definition) Derive a default bean name from the given bean definition.protected StringbuildDefaultBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) Derive a default bean name from the given bean definition.protected StringdetermineBeanNameFromAnnotation(AnnotatedBeanDefinition annotatedDef) Derive a bean name from one of the annotations on the class.generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) protected booleanisStereotype(String annotationType, Set<String> metaAnnotationTypes) Check whether the given annotation is a stereotype that is allowed to suggest a component name through its annotationvalue().
-
字段详细资料
-
INSTANCE
A convenient constant for a defaultAnnotationBeanNameGeneratorinstance, as used for component scanning purposes.
-
-
构造器详细资料
-
AnnotationBeanNameGenerator
public AnnotationBeanNameGenerator()
-
-
方法详细资料
-
generateBeanName
- 指定者:
generateBeanName在接口中BeanNameGenerator
-
determineBeanNameFromAnnotation
Derive a bean name from one of the annotations on the class.- 参数:
annotatedDef- the annotation-aware bean definition- 返回:
- the bean name, or
nullif none is found
-
isStereotype
Check whether the given annotation is a stereotype that is allowed to suggest a component name through its annotationvalue().- 参数:
annotationType- the name of the annotation class to checkmetaAnnotationTypes- the names of meta-annotations on the given annotation- 返回:
- whether the annotation qualifies as a stereotype with component name
-
buildDefaultBeanName
Derive a default bean name from the given bean definition.The default implementation delegates to
buildDefaultBeanName(BeanDefinition).- 参数:
definition- the bean definition to build a bean name forregistry- the registry that the given bean definition is being registered with- 返回:
- the default bean name (never
null)
-
buildDefaultBeanName
Derive a default bean name from the given bean definition.The default implementation simply builds a decapitalized version of the short class name: e.g. "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.
- 参数:
definition- the bean definition to build a bean name for- 返回:
- the default bean name (never
null)
-