Java Code Examples for org.springframework.context.annotation.ConfigurationClassPostProcessor#postProcessBeanFactory()
The following examples show how to use
org.springframework.context.annotation.ConfigurationClassPostProcessor#postProcessBeanFactory() .
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 File: ConfigurationClassProcessingTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Creates a new {@link BeanFactory}, populates it with a {@link BeanDefinition} for * each of the given {@link Configuration} <var>configClasses</var>, and then * post-processes the factory using JavaConfig's {@link ConfigurationClassPostProcessor}. * When complete, the factory is ready to service requests for any {@link Bean} methods * declared by <var>configClasses</var>. */ private ListableBeanFactory initBeanFactory(Class<?>... configClasses) { DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); for (Class<?> configClass : configClasses) { String configBeanName = configClass.getName(); factory.registerBeanDefinition(configBeanName, new RootBeanDefinition(configClass)); } ConfigurationClassPostProcessor ccpp = new ConfigurationClassPostProcessor(); ccpp.postProcessBeanDefinitionRegistry(factory); ccpp.postProcessBeanFactory(factory); RequiredAnnotationBeanPostProcessor rapp = new RequiredAnnotationBeanPostProcessor(); rapp.setBeanFactory(factory); factory.addBeanPostProcessor(rapp); factory.freezeConfiguration(); return factory; }
Example 2
Source File: ConfigurationClassProcessingTests.java From spring-analysis-note with MIT License | 5 votes |
/** * Creates a new {@link BeanFactory}, populates it with a {@link BeanDefinition} * for each of the given {@link Configuration} {@code configClasses}, and then * post-processes the factory using JavaConfig's {@link ConfigurationClassPostProcessor}. * When complete, the factory is ready to service requests for any {@link Bean} methods * declared by {@code configClasses}. */ private DefaultListableBeanFactory initBeanFactory(Class<?>... configClasses) { DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); for (Class<?> configClass : configClasses) { String configBeanName = configClass.getName(); factory.registerBeanDefinition(configBeanName, new RootBeanDefinition(configClass)); } ConfigurationClassPostProcessor ccpp = new ConfigurationClassPostProcessor(); ccpp.postProcessBeanDefinitionRegistry(factory); ccpp.postProcessBeanFactory(factory); factory.freezeConfiguration(); return factory; }
Example 3
Source File: ImportTests.java From spring-analysis-note with MIT License | 5 votes |
private DefaultListableBeanFactory processConfigurationClasses(Class<?>... classes) { DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); for (Class<?> clazz : classes) { beanFactory.registerBeanDefinition(clazz.getSimpleName(), new RootBeanDefinition(clazz)); } ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); pp.postProcessBeanFactory(beanFactory); return beanFactory; }
Example 4
Source File: ImportTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testProcessImportsWithAsm() { int configClasses = 2; int beansInClasses = 2; DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); beanFactory.registerBeanDefinition("config", new RootBeanDefinition(ConfigurationWithImportAnnotation.class.getName())); ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); pp.postProcessBeanFactory(beanFactory); assertThat(beanFactory.getBeanDefinitionCount(), equalTo(configClasses + beansInClasses)); }
Example 5
Source File: ImportTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testImportAnnotationWithMultipleArgumentsResultingInOverriddenBeanDefinition() { DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); beanFactory.registerBeanDefinition("config", new RootBeanDefinition( WithMultipleArgumentsThatWillCauseDuplication.class)); ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); pp.postProcessBeanFactory(beanFactory); assertThat(beanFactory.getBeanDefinitionCount(), equalTo(4)); assertThat(beanFactory.getBean("foo", ITestBean.class).getName(), equalTo("foo2")); }
Example 6
Source File: BeanAnnotationAttributePropagationTests.java From spring-analysis-note with MIT License | 5 votes |
private AbstractBeanDefinition beanDef(Class<?> configClass) { DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); factory.registerBeanDefinition("config", new RootBeanDefinition(configClass)); ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); pp.postProcessBeanFactory(factory); return (AbstractBeanDefinition) factory.getBeanDefinition("foo"); }
Example 7
Source File: ConfigurationClassProcessingTests.java From java-technology-stack with MIT License | 5 votes |
/** * Creates a new {@link BeanFactory}, populates it with a {@link BeanDefinition} * for each of the given {@link Configuration} {@code configClasses}, and then * post-processes the factory using JavaConfig's {@link ConfigurationClassPostProcessor}. * When complete, the factory is ready to service requests for any {@link Bean} methods * declared by {@code configClasses}. */ private DefaultListableBeanFactory initBeanFactory(Class<?>... configClasses) { DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); for (Class<?> configClass : configClasses) { String configBeanName = configClass.getName(); factory.registerBeanDefinition(configBeanName, new RootBeanDefinition(configClass)); } ConfigurationClassPostProcessor ccpp = new ConfigurationClassPostProcessor(); ccpp.postProcessBeanDefinitionRegistry(factory); ccpp.postProcessBeanFactory(factory); factory.freezeConfiguration(); return factory; }
Example 8
Source File: ImportTests.java From java-technology-stack with MIT License | 5 votes |
private DefaultListableBeanFactory processConfigurationClasses(Class<?>... classes) { DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); for (Class<?> clazz : classes) { beanFactory.registerBeanDefinition(clazz.getSimpleName(), new RootBeanDefinition(clazz)); } ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); pp.postProcessBeanFactory(beanFactory); return beanFactory; }
Example 9
Source File: ImportTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testProcessImportsWithAsm() { int configClasses = 2; int beansInClasses = 2; DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); beanFactory.registerBeanDefinition("config", new RootBeanDefinition(ConfigurationWithImportAnnotation.class.getName())); ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); pp.postProcessBeanFactory(beanFactory); assertThat(beanFactory.getBeanDefinitionCount(), equalTo(configClasses + beansInClasses)); }
Example 10
Source File: ImportTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testImportAnnotationWithMultipleArgumentsResultingInOverriddenBeanDefinition() { DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); beanFactory.registerBeanDefinition("config", new RootBeanDefinition( WithMultipleArgumentsThatWillCauseDuplication.class)); ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); pp.postProcessBeanFactory(beanFactory); assertThat(beanFactory.getBeanDefinitionCount(), equalTo(4)); assertThat(beanFactory.getBean("foo", ITestBean.class).getName(), equalTo("foo2")); }
Example 11
Source File: BeanAnnotationAttributePropagationTests.java From java-technology-stack with MIT License | 5 votes |
private AbstractBeanDefinition beanDef(Class<?> configClass) { DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); factory.registerBeanDefinition("config", new RootBeanDefinition(configClass)); ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); pp.postProcessBeanFactory(factory); return (AbstractBeanDefinition) factory.getBeanDefinition("foo"); }
Example 12
Source File: ImportTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
private DefaultListableBeanFactory processConfigurationClasses(Class<?>... classes) { DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); for (Class<?> clazz : classes) { beanFactory.registerBeanDefinition(clazz.getSimpleName(), new RootBeanDefinition(clazz)); } ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); pp.postProcessBeanFactory(beanFactory); return beanFactory; }
Example 13
Source File: ImportTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testProcessImportsWithAsm() { int configClasses = 2; int beansInClasses = 2; DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); beanFactory.registerBeanDefinition("config", new RootBeanDefinition(ConfigurationWithImportAnnotation.class.getName())); ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); pp.postProcessBeanFactory(beanFactory); assertThat(beanFactory.getBeanDefinitionCount(), equalTo(configClasses + beansInClasses)); }
Example 14
Source File: ImportTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testImportAnnotationWithMultipleArgumentsResultingInOverriddenBeanDefinition() { DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); beanFactory.registerBeanDefinition("config", new RootBeanDefinition( WithMultipleArgumentsThatWillCauseDuplication.class)); ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); pp.postProcessBeanFactory(beanFactory); assertThat(beanFactory.getBeanDefinitionCount(), equalTo(4)); assertThat(beanFactory.getBean("foo", ITestBean.class).getName(), equalTo("foo2")); }
Example 15
Source File: BeanAnnotationAttributePropagationTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
private AbstractBeanDefinition beanDef(Class<?> configClass) { DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); factory.registerBeanDefinition("config", new RootBeanDefinition(configClass)); ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); pp.postProcessBeanFactory(factory); return (AbstractBeanDefinition) factory.getBeanDefinition("foo"); }