Java Code Examples for org.springframework.context.annotation.AnnotationConfigApplicationContext#setBeanNameGenerator()
The following examples show how to use
org.springframework.context.annotation.AnnotationConfigApplicationContext#setBeanNameGenerator() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spring-analysis-note File: ConfigurationBeanNameTests.java License: MIT License | 6 votes |
@Test public void registerOuterConfig_withBeanNameGenerator() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); 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"), is(true)); assertThat(ctx.containsBean("custom-imported"), is(true)); assertThat(ctx.containsBean("custom-nested"), is(true)); assertThat(ctx.containsBean("nestedBean"), is(true)); }
Example 2
Source Project: java-technology-stack File: ConfigurationBeanNameTests.java License: MIT License | 6 votes |
@Test public void registerOuterConfig_withBeanNameGenerator() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); 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"), is(true)); assertThat(ctx.containsBean("custom-imported"), is(true)); assertThat(ctx.containsBean("custom-nested"), is(true)); assertThat(ctx.containsBean("nestedBean"), is(true)); }
Example 3
Source Project: spring4-understanding File: ConfigurationBeanNameTests.java License: Apache License 2.0 | 6 votes |
@Test public void registerOuterConfig_withBeanNameGenerator() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); 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"), is(true)); assertThat(ctx.containsBean("custom-imported"), is(true)); assertThat(ctx.containsBean("custom-nested"), is(true)); assertThat(ctx.containsBean("nestedBean"), is(true)); }