Java 类org.springframework.beans.factory.support.DefaultBeanNameGenerator 实例源码

项目:play-java-spring-data-jpa    文件:GuiceModuleRegistrar.java   
@Override
public void registerBeanDefinitions(AnnotationMetadata annotation,
        BeanDefinitionRegistry registry) {
    BeanDefinitionBuilder builder = BeanDefinitionBuilder
            .genericBeanDefinition(GuiceModuleMetadataFactory.class);
    builder.addPropertyValue("includeFilters",
            parseFilters(annotation, "includeFilters"));
    builder.addPropertyValue("excludeFilters",
            parseFilters(annotation, "excludeFilters"));
    builder.addPropertyValue("includePatterns",
            parsePatterns(annotation, "includePatterns"));
    builder.addPropertyValue("excludePatterns",
            parsePatterns(annotation, "excludePatterns"));
    builder.addPropertyValue("includeNames",
            parseNames(annotation, "includeNames"));
    builder.addPropertyValue("excludeNames",
            parseNames(annotation, "excludeNames"));
    AbstractBeanDefinition definition = builder.getBeanDefinition();
    String name = new DefaultBeanNameGenerator().generateBeanName(definition,
            registry);
    registry.registerBeanDefinition(name, definition);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SpringApplicationTests.java   
@Test
public void customBeanNameGenerator() throws Exception {
    TestSpringApplication application = new TestSpringApplication(
            ExampleWebConfig.class);
    BeanNameGenerator beanNameGenerator = new DefaultBeanNameGenerator();
    application.setBeanNameGenerator(beanNameGenerator);
    this.context = application.run();
    verify(application.getLoader()).setBeanNameGenerator(beanNameGenerator);
    Object actualGenerator = this.context
            .getBean(AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR);
    assertThat(actualGenerator).isSameAs(beanNameGenerator);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SpringApplicationTests.java   
@Test
public void customBeanNameGeneratorWithNonWebApplication() throws Exception {
    TestSpringApplication application = new TestSpringApplication(
            ExampleWebConfig.class);
    application.setWebEnvironment(false);
    BeanNameGenerator beanNameGenerator = new DefaultBeanNameGenerator();
    application.setBeanNameGenerator(beanNameGenerator);
    this.context = application.run();
    verify(application.getLoader()).setBeanNameGenerator(beanNameGenerator);
    Object actualGenerator = this.context
            .getBean(AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR);
    assertThat(actualGenerator).isSameAs(beanNameGenerator);
}
项目:spring-boot-concourse    文件:SpringApplicationTests.java   
@Test
public void customBeanNameGenerator() throws Exception {
    TestSpringApplication application = new TestSpringApplication(
            ExampleWebConfig.class);
    BeanNameGenerator beanNameGenerator = new DefaultBeanNameGenerator();
    application.setBeanNameGenerator(beanNameGenerator);
    this.context = application.run();
    verify(application.getLoader()).setBeanNameGenerator(beanNameGenerator);
    Object bean = this.context
            .getBean(AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR);
    assertThat(bean).isSameAs(beanNameGenerator);
}
项目:contestparser    文件:SpringApplicationTests.java   
@Test
public void customBeanNameGenerator() throws Exception {
    TestSpringApplication application = new TestSpringApplication(
            ExampleWebConfig.class);
    BeanNameGenerator beanNameGenerator = new DefaultBeanNameGenerator();
    application.setBeanNameGenerator(beanNameGenerator);
    this.context = application.run();
    verify(application.getLoader()).setBeanNameGenerator(beanNameGenerator);
    assertThat(
            this.context
                    .getBean(AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR),
            sameInstance((Object) beanNameGenerator));
}
项目:dwr    文件:AnnotationScannerParser.java   
public BeanDefinition parse(Element element, ParserContext parserContext)
{
    ClassPathBeanDefinitionScanner scanner = new DwrClassPathBeanDefinitionScanner(parserContext.getRegistry());
    String basePackage = element.getAttribute("base-package");
    // Override - By default Spring uses a name generator that uses AnnotationBeanNameGenerator which uses the name specified on the Component
    // annotation and if not present uses the simple name.  Since our annotation-scanner doesn't scan @Component if two classes with the
    // same simple name exist in different packages there will be issues.  See https://directwebremoting.atlassian.net/browse/DWR-651.
    scanner.setBeanNameGenerator(new DefaultBeanNameGenerator());
    if (!hasText(basePackage))
    {
        if (log.isInfoEnabled())
        {
            log.info("No base package defined for classpath scanning. Traversing the whole JVM classpath");
        }
    }
    String regex = element.getAttribute("regex");
    if (hasText(regex))
    {
        scanner.addIncludeFilter(new RegexPatternTypeFilter(Pattern.compile(regex)));
    }
    String proxies = element.getAttribute("scanRemoteProxy");
    if (hasText(proxies) && ("TRUE".equals(proxies.toUpperCase()) || "FALSE".equals(proxies.toUpperCase())))
    {
        scanProxies = Boolean.parseBoolean(proxies);
    }
    if (scanProxies)
    {
        scanner.addIncludeFilter(new AnnotationTypeFilter(RemoteProxy.class));
    }
    String conv = element.getAttribute("scanDataTransferObject");
    if (hasText(conv) && ("TRUE".equals(conv.toUpperCase()) || "FALSE".equals(conv.toUpperCase())))
    {
        scanConverters = Boolean.parseBoolean(conv);
    }
    if (scanConverters)
    {
        scanner.addIncludeFilter(new AnnotationTypeFilter(DataTransferObject.class));
    }
    String filters = element.getAttribute("scanGlobalFilter");
    if (hasText(filters) && ("TRUE".equals(filters.toUpperCase()) || "FALSE".equals(filters.toUpperCase())))
    {
        scanFilters = Boolean.parseBoolean(filters);
    }
    if (scanFilters)
    {
        scanner.addIncludeFilter(new AnnotationTypeFilter(GlobalFilter.class));
    }
    if (scanProxies | scanConverters | scanFilters)
    {
        scanner.scan(basePackage == null ? "" : basePackage);
    }
    else
    {
        log.warn("Scan is not required if all @RemoteProxy, @DataTransferObject and @GlobalFilter are disabled. Skipping detection");
    }
    return null;
}