/** * 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; }
/** * 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); return factory; }