/**
* 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;
}
java类org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor的实例源码
ConfigurationClassProcessingTests.java 文件源码
项目:spring4-understanding
阅读 31
收藏 0
点赞 0
评论 0
ConfigurationClassProcessingTests.java 文件源码
项目:class-guard
阅读 29
收藏 0
点赞 0
评论 0
/**
* 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;
}