Java 类org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor 实例源码

项目:spring4-understanding    文件:ConfigurationClassProcessingTests.java   
/**
 * 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;
}
项目:class-guard    文件:ConfigurationClassProcessingTests.java   
/**
 * 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;
}