use of cn.taketoday.context.annotation.AnnotationBeanNameGenerator in project today-infrastructure by TAKETODAY.
the class ConfigurationBeanNameTests method registerOuterConfig_withBeanNameGenerator.
@Test
public void registerOuterConfig_withBeanNameGenerator() {
StandardApplicationContext ctx = new StandardApplicationContext();
ctx.setBeanNameGenerator(new AnnotationBeanNameGenerator() {
@Override
public String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) {
return "custom-" + super.generateBeanName(definition, registry);
}
});
ctx.register(A.class);
ctx.refresh();
assertThat(ctx.containsBean("custom-outer")).isTrue();
assertThat(ctx.containsBean("custom-imported")).isTrue();
assertThat(ctx.containsBean("custom-nested")).isTrue();
assertThat(ctx.containsBean("nestedBean")).isTrue();
}
use of cn.taketoday.context.annotation.AnnotationBeanNameGenerator in project today-framework by TAKETODAY.
the class ConfigurationBeanNameTests method registerOuterConfig_withBeanNameGenerator.
@Test
public void registerOuterConfig_withBeanNameGenerator() {
StandardApplicationContext ctx = new StandardApplicationContext();
ctx.setBeanNameGenerator(new AnnotationBeanNameGenerator() {
@Override
public String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) {
return "custom-" + super.generateBeanName(definition, registry);
}
});
ctx.register(A.class);
ctx.refresh();
assertThat(ctx.containsBean("custom-outer")).isTrue();
assertThat(ctx.containsBean("custom-imported")).isTrue();
assertThat(ctx.containsBean("custom-nested")).isTrue();
assertThat(ctx.containsBean("nestedBean")).isTrue();
}
Aggregations