I have few classes that I need to annotate with a name so I defined my annotation as
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @i
You can provide a custom BeanNameGenerator to the ClassPathBeanDefinitionScanner, which can look for the value of your annotation and return that as the bean name.
I think an implementation along these lines should work for you.
package org.bk.lmt.services;
import java.util.Map;
import java.util.Set;
import org.springframework.context.annotation.AnnotationBeanNameGenerator;
public class CustomBeanNameGenerator extends AnnotationBeanNameGenerator{
@Override
protected boolean isStereotypeWithNameValue(String annotationType,
Set metaAnnotationTypes, Map attributes) {
return annotationType.equals("services.JsonUnmarshallable");
}
}
Add this to your previous scanner code:
scanner.setBeanNameGenerator(new CustomBeanNameGenerator());