Java 类org.springframework.context.annotation.AnnotatedBeanDefinitionReader 实例源码

项目:spring4-understanding    文件:SpringAtInjectTck.java   
public static Test suite() {
    GenericApplicationContext ac = new GenericApplicationContext();
    AnnotatedBeanDefinitionReader bdr = new AnnotatedBeanDefinitionReader(ac);
    bdr.setScopeMetadataResolver(new Jsr330ScopeMetadataResolver());

    bdr.registerBean(Convertible.class);
    bdr.registerBean(DriversSeat.class, Drivers.class);
    bdr.registerBean(Seat.class, Primary.class);
    bdr.registerBean(V8Engine.class);
    bdr.registerBean(SpareTire.class, "spare");
    bdr.registerBean(Cupholder.class);
    bdr.registerBean(Tire.class, Primary.class);
    bdr.registerBean(FuelTank.class);

    ac.refresh();
    Car car = ac.getBean(Car.class);

    return Tck.testsFor(car, false, true);
}
项目:spring4-understanding    文件:EnvironmentSecurityManagerIntegrationTests.java   
@Test
public void securityManagerDisallowsAccessToSystemEnvironmentButAllowsAccessToIndividualKeys() {
    SecurityManager securityManager = new SecurityManager() {
        @Override
        public void checkPermission(Permission perm) {
            // Disallowing access to System#getenv means that our
            // ReadOnlySystemAttributesMap will come into play.
            if ("getenv.*".equals(perm.getName())) {
                throw new AccessControlException("Accessing the system environment is disallowed");
            }
        }
    };
    System.setSecurityManager(securityManager);

    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
    AnnotatedBeanDefinitionReader reader = new AnnotatedBeanDefinitionReader(bf);
    reader.register(C1.class);
    assertThat(bf.containsBean("c1"), is(true));
}
项目:spring4-understanding    文件:CustomRequestAttributesRequestContextHolderTests.java   
@Before
public void setUp() {
    ServletContext servletContext = new MockServletContext();
    MockHttpServletRequest mockRequest = new MockHttpServletRequest(servletContext);
    mockRequest.setAttribute(FROM_CUSTOM_MOCK, FROM_CUSTOM_MOCK);
    RequestContextHolder.setRequestAttributes(new ServletWebRequest(mockRequest, new MockHttpServletResponse()));

    this.wac.setServletContext(servletContext);
    new AnnotatedBeanDefinitionReader(this.wac).register(WebConfig.class);
    this.wac.refresh();

    this.mockMvc = webAppContextSetup(this.wac)
            .defaultRequest(get("/").requestAttr(FROM_MVC_TEST_DEFAULT, FROM_MVC_TEST_DEFAULT))
            .alwaysExpect(status().isOk())
            .build();
}
项目:class-guard    文件:SpringAtInjectTck.java   
public static Test suite() {
    GenericApplicationContext ac = new GenericApplicationContext();
    AnnotatedBeanDefinitionReader bdr = new AnnotatedBeanDefinitionReader(ac);
    bdr.setScopeMetadataResolver(new Jsr330ScopeMetadataResolver());

    bdr.registerBean(Convertible.class);
    bdr.registerBean(DriversSeat.class, Drivers.class);
    bdr.registerBean(Seat.class, Primary.class);
    bdr.registerBean(V8Engine.class);
    bdr.registerBean(SpareTire.class, "spare");
    bdr.registerBean(Cupholder.class);
    bdr.registerBean(Tire.class, Primary.class);
    bdr.registerBean(FuelTank.class);

    ac.refresh();
    Car car = ac.getBean(Car.class);

    return Tck.testsFor(car, false, true);
}
项目:class-guard    文件:EnvironmentSecurityManagerIntegrationTests.java   
@Test
public void securityManagerDisallowsAccessToSystemEnvironmentButAllowsAccessToIndividualKeys() {
    SecurityManager securityManager = new SecurityManager() {
        @Override
        public void checkPermission(Permission perm) {
            // disallowing access to System#getenv means that our
            // ReadOnlySystemAttributesMap will come into play.
            if ("getenv.*".equals(perm.getName())) {
                throw new AccessControlException(
                        "Accessing the system environment is disallowed");
            }
        }
    };
    System.setSecurityManager(securityManager);

    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
    AnnotatedBeanDefinitionReader reader = new AnnotatedBeanDefinitionReader(bf);
    reader.register(C1.class);
    assertThat(bf.containsBean("c1"), is(true));
}
项目:score    文件:EngineBeanDefinitionParser.java   
private void loadContexts(Element element, BeanDefinitionRegistry beanDefinitionRegistry) {
    String externalDatabase = element.getAttribute("externalDatabase");
    if (StringUtils.isBlank(externalDatabase) || externalDatabase.equals(Boolean.FALSE.toString())) {
        AnnotatedBeanDefinitionReader definitionReader = new AnnotatedBeanDefinitionReader(beanDefinitionRegistry);
        definitionReader.register(ScoreDefaultDatasourceContext.class);
        definitionReader.register(ScoreDatabaseContext.class);
    }

    String repositoriesContextPath = "META-INF/spring/score/context/scoreRepositoryContext.xml";

    String ignoreEngineJobs = element.getAttribute("ignoreEngineJobs");
    if(StringUtils.isNotBlank(ignoreEngineJobs) && ignoreEngineJobs.equals(Boolean.TRUE.toString())){
        new XmlBeanDefinitionReader(beanDefinitionRegistry).loadBeanDefinitions(repositoriesContextPath);
    }
    else{
        new XmlBeanDefinitionReader(beanDefinitionRegistry).loadBeanDefinitions(repositoriesContextPath,ENGINE_JOBS_CONTEXT_LOCATION);
    }
}
项目:spring4-understanding    文件:EnvironmentSecurityManagerIntegrationTests.java   
@Test
public void securityManagerDisallowsAccessToSystemEnvironmentAndDisallowsAccessToIndividualKey() {
    SecurityManager securityManager = new SecurityManager() {
        @Override
        public void checkPermission(Permission perm) {
            // Disallowing access to System#getenv means that our
            // ReadOnlySystemAttributesMap will come into play.
            if ("getenv.*".equals(perm.getName())) {
                throw new AccessControlException("Accessing the system environment is disallowed");
            }
            // Disallowing access to the spring.profiles.active property means that
            // the BeanDefinitionReader won't be able to determine which profiles are
            // active. We should see an INFO-level message in the console about this
            // and as a result, any components marked with a non-default profile will
            // be ignored.
            if (("getenv." + AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME).equals(perm.getName())) {
                throw new AccessControlException(
                        format("Accessing system environment variable [%s] is disallowed",
                                AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME));
            }
        }
    };
    System.setSecurityManager(securityManager);

    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
    AnnotatedBeanDefinitionReader reader = new AnnotatedBeanDefinitionReader(bf);
    reader.register(C1.class);
    assertThat(bf.containsBean("c1"), is(false));
}
项目:spring4-understanding    文件:EnvironmentSystemIntegrationTests.java   
@Test
public void annotatedBeanDefinitionReader_inheritsEnvironmentFromEnvironmentCapableBDR() {
    GenericApplicationContext ctx = new GenericApplicationContext();
    ctx.setEnvironment(prodEnv);
    new AnnotatedBeanDefinitionReader(ctx).register(Config.class);
    ctx.refresh();
    assertThat(ctx.containsBean(DEV_BEAN_NAME), is(false));
    assertThat(ctx.containsBean(PROD_BEAN_NAME), is(true));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:BeanDefinitionLoader.java   
/**
 * Create a new {@link BeanDefinitionLoader} that will load beans into the specified
 * {@link BeanDefinitionRegistry}.
 * @param registry the bean definition registry that will contain the loaded beans
 * @param sources the bean sources
 */
BeanDefinitionLoader(BeanDefinitionRegistry registry, Object... sources) {
    Assert.notNull(registry, "Registry must not be null");
    Assert.notEmpty(sources, "Sources must not be empty");
    this.sources = sources;
    this.annotatedReader = new AnnotatedBeanDefinitionReader(registry);
    this.xmlReader = new XmlBeanDefinitionReader(registry);
    if (isGroovyPresent()) {
        this.groovyReader = new GroovyBeanDefinitionReader(registry);
    }
    this.scanner = new ClassPathBeanDefinitionScanner(registry);
    this.scanner.addExcludeFilter(new ClassExcludeFilter(sources));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ImportsContextCustomizer.java   
@Override
public void customizeContext(ConfigurableApplicationContext context,
        MergedContextConfiguration mergedContextConfiguration) {
    BeanDefinitionRegistry registry = getBeanDefinitionRegistry(context);
    AnnotatedBeanDefinitionReader reader = new AnnotatedBeanDefinitionReader(
            registry);
    registerCleanupPostProcessor(registry, reader);
    registerImportsConfiguration(registry, reader);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ImportsContextCustomizer.java   
private void registerCleanupPostProcessor(BeanDefinitionRegistry registry,
        AnnotatedBeanDefinitionReader reader) {
    BeanDefinition definition = registerBean(registry, reader,
            ImportsCleanupPostProcessor.BEAN_NAME, ImportsCleanupPostProcessor.class);
    definition.getConstructorArgumentValues().addIndexedArgumentValue(0,
            this.testClass);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ImportsContextCustomizer.java   
@SuppressWarnings("unchecked")
private BeanDefinition registerBean(BeanDefinitionRegistry registry,
        AnnotatedBeanDefinitionReader reader, String beanName, Class<?> type) {
    reader.registerBean(type, beanName);
    BeanDefinition definition = registry.getBeanDefinition(beanName);
    return definition;
}
项目:spring-boot-concourse    文件:BeanDefinitionLoader.java   
/**
 * Create a new {@link BeanDefinitionLoader} that will load beans into the specified
 * {@link BeanDefinitionRegistry}.
 * @param registry the bean definition registry that will contain the loaded beans
 * @param sources the bean sources
 */
BeanDefinitionLoader(BeanDefinitionRegistry registry, Object... sources) {
    Assert.notNull(registry, "Registry must not be null");
    Assert.notEmpty(sources, "Sources must not be empty");
    this.sources = sources;
    this.annotatedReader = new AnnotatedBeanDefinitionReader(registry);
    this.xmlReader = new XmlBeanDefinitionReader(registry);
    if (isGroovyPresent()) {
        this.groovyReader = new GroovyBeanDefinitionReader(registry);
    }
    this.scanner = new ClassPathBeanDefinitionScanner(registry);
    this.scanner.addExcludeFilter(new ClassExcludeFilter(sources));
}
项目:spring-boot-concourse    文件:ImportsContextCustomizer.java   
@Override
public void customizeContext(ConfigurableApplicationContext context,
        MergedContextConfiguration mergedContextConfiguration) {
    BeanDefinitionRegistry registry = getBeanDefinitionRegistry(context);
    AnnotatedBeanDefinitionReader reader = new AnnotatedBeanDefinitionReader(
            registry);
    registerCleanupPostProcessor(registry, reader);
    registerImportsConfiguration(registry, reader);
}
项目:spring-boot-concourse    文件:ImportsContextCustomizer.java   
private void registerCleanupPostProcessor(BeanDefinitionRegistry registry,
        AnnotatedBeanDefinitionReader reader) {
    BeanDefinition definition = registerBean(registry, reader,
            ImportsCleanupPostProcessor.BEAN_NAME, ImportsCleanupPostProcessor.class);
    definition.getConstructorArgumentValues().addIndexedArgumentValue(0,
            this.testClass);
}
项目:spring-boot-concourse    文件:ImportsContextCustomizer.java   
@SuppressWarnings("unchecked")
private BeanDefinition registerBean(BeanDefinitionRegistry registry,
        AnnotatedBeanDefinitionReader reader, String beanName, Class<?> type) {
    reader.registerBean(type, beanName);
    BeanDefinition definition = registry.getBeanDefinition(beanName);
    return definition;
}
项目:Mycat-openEP    文件:SpringInitializer.java   
private static void initAnnotatedConf(GenericApplicationContext context){
    Class componentScanAnnotated=ProcessInfo.getAnnotationInitClass();
    if(componentScanAnnotated!=null){
        AnnotatedGenericBeanDefinition def=new AnnotatedGenericBeanDefinition(ProcessInfo.getAnnotationInitClass());
        AnnotatedBeanDefinitionReader reader=new AnnotatedBeanDefinitionReader(context);
        AnnotationScopeMetadataResolver resolver=new AnnotationScopeMetadataResolver();
        resolver.resolveScopeMetadata(def);
        reader.setScopeMetadataResolver(resolver);
    }
}
项目:contestparser    文件:BeanDefinitionLoader.java   
/**
 * Create a new {@link BeanDefinitionLoader} that will load beans into the specified
 * {@link BeanDefinitionRegistry}.
 * @param registry the bean definition registry that will contain the loaded beans
 * @param sources the bean sources
 */
BeanDefinitionLoader(BeanDefinitionRegistry registry, Object... sources) {
    Assert.notNull(registry, "Registry must not be null");
    Assert.notEmpty(sources, "Sources must not be empty");
    this.sources = sources;
    this.annotatedReader = new AnnotatedBeanDefinitionReader(registry);
    this.xmlReader = new XmlBeanDefinitionReader(registry);
    if (isGroovyPresent()) {
        this.groovyReader = new GroovyBeanDefinitionReader(registry);
    }
    this.scanner = new ClassPathBeanDefinitionScanner(registry);
    this.scanner.addExcludeFilter(new ClassExcludeFilter(sources));
}
项目:class-guard    文件:EnvironmentSecurityManagerIntegrationTests.java   
@Test
public void securityManagerDisallowsAccessToSystemEnvironmentAndDisallowsAccessToIndividualKey() {
    SecurityManager securityManager = new SecurityManager() {
        @Override
        public void checkPermission(Permission perm) {
            // disallowing access to System#getenv means that our
            // ReadOnlySystemAttributesMap will come into play.
            if ("getenv.*".equals(perm.getName())) {
                throw new AccessControlException(
                        "Accessing the system environment is disallowed");
            }
            // disallowing access to the spring.profiles.active property means that
            // the BeanDefinitionReader won't be able to determine which profiles are
            // active. We should see an INFO-level message in the console about this
            // and as a result, any components marked with a non-default profile will
            // be ignored.
            if (("getenv."+AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME).equals(perm.getName())) {
                throw new AccessControlException(
                        format("Accessing system environment variable [%s] is disallowed",
                                AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME));
            }
        }
    };
    System.setSecurityManager(securityManager);

    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
    AnnotatedBeanDefinitionReader reader = new AnnotatedBeanDefinitionReader(bf);
    reader.register(C1.class);
    assertThat(bf.containsBean("c1"), is(false));
}
项目:class-guard    文件:EnvironmentIntegrationTests.java   
@Test
public void annotatedBeanDefinitionReader_inheritsEnvironmentFromEnvironmentCapableBDR() {
    GenericApplicationContext ctx = new GenericApplicationContext();
    ctx.setEnvironment(prodEnv);
    new AnnotatedBeanDefinitionReader(ctx).register(Config.class);
    ctx.refresh();
    assertThat(ctx.containsBean(DEV_BEAN_NAME), is(false));
    assertThat(ctx.containsBean(PROD_BEAN_NAME), is(true));
}
项目:mev    文件:MapHotPlugViewRegistry.java   
@Override
public AnnotatedClassViewRegistrar register (Class<?> first, Class<?>... rest) {
  try (GenericWebApplicationContext context = createContext ()) {
    AnnotatedBeanDefinitionReader reader = createAnnotatedReader (context);

    reader.register (first);
    reader.register (rest);

    context.refresh ();

    mergeViews (context);
  }
  return this;
}
项目:springboot-analysis    文件:SpringEmbeddedProviderTest.java   
@Test
public void testAnnotatedBeanDefinitionReader() {
    AnnotatedBeanDefinitionReader annotatedReader = new AnnotatedBeanDefinitionReader(beanDefinitionRegistry);
    annotatedReader.register(CustomComponentProviderApplication.class);
}
项目:spring-seed    文件:SpringBatchApplicationContext.java   
public SpringBatchApplicationContext(boolean allowBeanDefinitionOverriding) {
    super();
    this.annotatedBeanReader = new AnnotatedBeanDefinitionReader(this);
    this.xmlBeanReader = new XmlBeanDefinitionReader(this);
    setAllowBeanDefinitionOverriding(allowBeanDefinitionOverriding);
}
项目:spring4-understanding    文件:HybridContextLoader.java   
@Override
protected void loadBeanDefinitions(GenericApplicationContext context, MergedContextConfiguration mergedConfig) {
    // Order doesn't matter: <bean> always wins over @Bean.
    new XmlBeanDefinitionReader(context).loadBeanDefinitions(mergedConfig.getLocations());
    new AnnotatedBeanDefinitionReader(context).register(mergedConfig.getClasses());
}
项目:spring4-understanding    文件:InitializerWithoutConfigFilesOrClassesTests.java   
@Override
public void initialize(GenericApplicationContext applicationContext) {
    new AnnotatedBeanDefinitionReader(applicationContext).register(GlobalConfig.class);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ImportsContextCustomizer.java   
private void registerImportsConfiguration(BeanDefinitionRegistry registry,
        AnnotatedBeanDefinitionReader reader) {
    BeanDefinition definition = registerBean(registry, reader,
            ImportsConfiguration.BEAN_NAME, ImportsConfiguration.class);
    definition.setAttribute(TEST_CLASS_ATTRIBUTE, this.testClass);
}
项目:spring-boot-concourse    文件:ImportsContextCustomizer.java   
private void registerImportsConfiguration(BeanDefinitionRegistry registry,
        AnnotatedBeanDefinitionReader reader) {
    BeanDefinition definition = registerBean(registry, reader,
            ImportsConfiguration.BEAN_NAME, ImportsConfiguration.class);
    definition.setAttribute(TEST_CLASS_ATTRIBUTE, this.testClass);
}
项目:class-guard    文件:InitializerWithoutConfigFilesOrClassesTest.java   
@Override
public void initialize(GenericApplicationContext applicationContext) {
    new AnnotatedBeanDefinitionReader(applicationContext).register(GlobalConfig.class);
}
项目:cims-server    文件:GenericWebContextLoader.java   
protected void loadBeanDefinitions(GenericWebApplicationContext context, MergedContextConfiguration mergedConfig) {
    new AnnotatedBeanDefinitionReader(context).register(mergedConfig.getClasses());
    loadBeanDefinitions(context, mergedConfig.getLocations());
}
项目:maven-framework-project    文件:GenericWebContextLoader.java   
protected void loadBeanDefinitions(GenericWebApplicationContext context, MergedContextConfiguration mergedConfig) {
    new AnnotatedBeanDefinitionReader(context).register(mergedConfig.getClasses());
    loadBeanDefinitions(context, mergedConfig.getLocations());
}
项目:maven-framework-project    文件:GenericWebContextLoader.java   
protected void loadBeanDefinitions(GenericWebApplicationContext context, MergedContextConfiguration mergedConfig) {
    new AnnotatedBeanDefinitionReader(context).register(mergedConfig.getClasses());
    loadBeanDefinitions(context, mergedConfig.getLocations());
}
项目:maven-framework-project    文件:GenericWebContextLoader.java   
protected void loadBeanDefinitions(GenericWebApplicationContext context, MergedContextConfiguration mergedConfig) {
    new AnnotatedBeanDefinitionReader(context).register(mergedConfig.getClasses());
    loadBeanDefinitions(context, mergedConfig.getLocations());
}
项目:mev    文件:MapHotPlugViewRegistry.java   
protected AnnotatedBeanDefinitionReader createAnnotatedReader (GenericWebApplicationContext context) {
  AnnotatedBeanDefinitionReader reader = new AnnotatedBeanDefinitionReader (context);
  reader.setEnvironment (getApplicationContext ().getEnvironment ());
  return reader;
}
项目:elasticactors    文件:AnnotationConfigApplicationContext.java   
/**
 * Create a new AnnotationConfigApplicationContext that needs to be populated
 * through {@link #register} calls and then manually {@linkplain #refresh refreshed}.
 */
public AnnotationConfigApplicationContext() {
    this.reader = new AnnotatedBeanDefinitionReader(this);
    this.scanner = new ClassPathBeanDefinitionScanner(this);
}
项目:openhds-server    文件:GenericWebContextLoader.java   
protected void loadBeanDefinitions(GenericWebApplicationContext context, MergedContextConfiguration mergedConfig) {
    new AnnotatedBeanDefinitionReader(context).register(mergedConfig.getClasses());
    loadBeanDefinitions(context, mergedConfig.getLocations());
}
项目:spring4-understanding    文件:AnnotationConfigWebContextLoader.java   
/**
 * Register classes in the supplied {@linkplain GenericWebApplicationContext context}
 * from the classes in the supplied {@link WebMergedContextConfiguration}.
 *
 * <p>Each class must represent an <em>annotated class</em>. An
 * {@link AnnotatedBeanDefinitionReader} is used to register the appropriate
 * bean definitions.
 *
 * @param context the context in which the annotated classes should be registered
 * @param webMergedConfig the merged configuration from which the classes should be retrieved
 *
 * @see AbstractGenericWebContextLoader#loadBeanDefinitions
 */
@Override
protected void loadBeanDefinitions(GenericWebApplicationContext context,
        WebMergedContextConfiguration webMergedConfig) {
    Class<?>[] annotatedClasses = webMergedConfig.getClasses();
    if (logger.isDebugEnabled()) {
        logger.debug("Registering annotated classes: " + ObjectUtils.nullSafeToString(annotatedClasses));
    }
    new AnnotatedBeanDefinitionReader(context).register(annotatedClasses);
}
项目:spring4-understanding    文件:AnnotationConfigContextLoader.java   
/**
 * Register classes in the supplied {@link GenericApplicationContext context}
 * from the classes in the supplied {@link MergedContextConfiguration}.
 *
 * <p>Each class must represent an <em>annotated class</em>. An
 * {@link AnnotatedBeanDefinitionReader} is used to register the appropriate
 * bean definitions.
 *
 * <p>Note that this method does not call {@link #createBeanDefinitionReader}
 * since {@code AnnotatedBeanDefinitionReader} is not an instance of
 * {@link BeanDefinitionReader}.
 *
 * @param context the context in which the annotated classes should be registered
 * @param mergedConfig the merged configuration from which the classes should be retrieved
 *
 * @see AbstractGenericContextLoader#loadBeanDefinitions
 */
@Override
protected void loadBeanDefinitions(GenericApplicationContext context, MergedContextConfiguration mergedConfig) {
    Class<?>[] annotatedClasses = mergedConfig.getClasses();
    if (logger.isDebugEnabled()) {
        logger.debug("Registering annotated classes: " + ObjectUtils.nullSafeToString(annotatedClasses));
    }
    new AnnotatedBeanDefinitionReader(context).register(annotatedClasses);
}
项目:class-guard    文件:AnnotationConfigWebContextLoader.java   
/**
 * Register classes in the supplied {@linkplain GenericWebApplicationContext context}
 * from the classes in the supplied {@link WebMergedContextConfiguration}.
 *
 * <p>Each class must represent an <em>annotated class</em>. An
 * {@link AnnotatedBeanDefinitionReader} is used to register the appropriate
 * bean definitions.
 *
 * @param context the context in which the annotated classes should be registered
 * @param webMergedConfig the merged configuration from which the classes should be retrieved
 *
 * @see AbstractGenericWebContextLoader#loadBeanDefinitions
 */
@Override
protected void loadBeanDefinitions(GenericWebApplicationContext context,
        WebMergedContextConfiguration webMergedConfig) {
    Class<?>[] annotatedClasses = webMergedConfig.getClasses();
    if (logger.isDebugEnabled()) {
        logger.debug("Registering annotated classes: " + ObjectUtils.nullSafeToString(annotatedClasses));
    }
    new AnnotatedBeanDefinitionReader(context).register(annotatedClasses);
}
项目:class-guard    文件:AnnotationConfigContextLoader.java   
/**
 * Register classes in the supplied {@link GenericApplicationContext context}
 * from the classes in the supplied {@link MergedContextConfiguration}.
 *
 * <p>Each class must represent an <em>annotated class</em>. An
 * {@link AnnotatedBeanDefinitionReader} is used to register the appropriate
 * bean definitions.
 *
 * <p>Note that this method does not call {@link #createBeanDefinitionReader}
 * since {@code AnnotatedBeanDefinitionReader} is not an instance of
 * {@link BeanDefinitionReader}.
 *
 * @param context the context in which the annotated classes should be registered
 * @param mergedConfig the merged configuration from which the classes should be retrieved
 *
 * @see AbstractGenericContextLoader#loadBeanDefinitions
 */
@Override
protected void loadBeanDefinitions(GenericApplicationContext context, MergedContextConfiguration mergedConfig) {
    Class<?>[] annotatedClasses = mergedConfig.getClasses();
    if (logger.isDebugEnabled()) {
        logger.debug("Registering annotated classes: " + ObjectUtils.nullSafeToString(annotatedClasses));
    }
    new AnnotatedBeanDefinitionReader(context).register(annotatedClasses);
}
项目:spring4-understanding    文件:AnnotationConfigWebApplicationContext.java   
/**
 * Build an {@link AnnotatedBeanDefinitionReader} for the given bean factory.
 * <p>This should be pre-configured with the {@code Environment} (if desired)
 * but not with a {@code BeanNameGenerator} or {@code ScopeMetadataResolver} yet.
 * @param beanFactory the bean factory to load bean definitions into
 * @since 4.1.9
 * @see #getEnvironment()
 * @see #getBeanNameGenerator()
 * @see #getScopeMetadataResolver()
 */
protected AnnotatedBeanDefinitionReader getAnnotatedBeanDefinitionReader(DefaultListableBeanFactory beanFactory) {
    return new AnnotatedBeanDefinitionReader(beanFactory, getEnvironment());
}