|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.context.annotation.AnnotationBeanNameGenerator
public class AnnotationBeanNameGenerator
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
.
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). For example:
com.xyz.FooServiceImpl -> fooServiceImpl
Component.value()
,
Repository.value()
,
Service.value()
,
Controller.value()
Constructor Summary | |
---|---|
AnnotationBeanNameGenerator()
|
Method Summary | |
---|---|
protected String |
buildDefaultBeanName(BeanDefinition definition)
Derive a default bean name from the given bean definition. |
protected 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,Object> attributes)
Check whether the given annotation is a stereotype that is allowed to suggest a component name through its annotation value() . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AnnotationBeanNameGenerator()
Method Detail |
---|
public String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry)
BeanNameGenerator
generateBeanName
in interface BeanNameGenerator
definition
- the bean definition to generate a name forregistry
- the bean definition registry that the given definition
is supposed to be registered with
protected String determineBeanNameFromAnnotation(AnnotatedBeanDefinition annotatedDef)
annotatedDef
- the annotation-aware bean definition
null
if none is foundprotected boolean isStereotypeWithNameValue(String annotationType, Set<String> metaAnnotationTypes, Map<String,Object> attributes)
value()
.
annotationType
- the name of the annotation class to checkmetaAnnotationTypes
- the names of meta-annotations on the given annotationattributes
- the map of attributes for the given annotation
protected String buildDefaultBeanName(BeanDefinition 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
null
)
|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |