Created
September 6, 2013 02:42
-
-
Save mythosil/6458902 to your computer and use it in GitHub Desktop.
bean-name-generator for annotated classes. generates FQDN bean name.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mythosil.spring.context; | |
import java.beans.Introspector; | |
import org.springframework.beans.factory.config.BeanDefinition; | |
import org.springframework.context.annotation.AnnotationBeanNameGenerator; | |
public class FQDNAnnotationBeanNameGenerator extends AnnotationBeanNameGenerator { | |
/** | |
* Derive a bean name from the given bean definition. | |
* <p>The implementation simply builds a decapitalized version | |
* of the FQDN: e.g. "mypackage.MyClass" -> "mypackage.myClass". | |
* <p>Note that inner classes will thus have names of the form | |
* "mypackage.myouterClass.innerClass", which because of the period | |
* in the name may be an issue if you are autowiring by name. | |
* @param definition the bean definition to build a bean name for | |
* @return the bean name (never {@code null}) | |
*/ | |
@Override | |
protected String buildDefaultBeanName(BeanDefinition definition) { | |
String fqdn = definition.getBeanClassName(); | |
return Introspector.decapitalize(fqdn); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment