Package org.springframework.beans.factory.support

Examples of org.springframework.beans.factory.support.BeanNameGenerator


  private ApplicationContext createContext(ScopedProxyMode scopedProxyMode) {
    GenericWebApplicationContext context = new GenericWebApplicationContext();
    ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context);
    scanner.setIncludeAnnotationConfig(false);
    scanner.setBeanNameGenerator(new BeanNameGenerator() {
      @Override
      public String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) {
        return definition.getScope();
      }
    });
View Full Code Here


    reader.setEnvironment(getEnvironment());

    ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(beanFactory);
    scanner.setEnvironment(getEnvironment());

    BeanNameGenerator beanNameGenerator = getBeanNameGenerator();
    ScopeMetadataResolver scopeMetadataResolver = getScopeMetadataResolver();
    if (beanNameGenerator != null) {
      reader.setBeanNameGenerator(beanNameGenerator);
      scanner.setBeanNameGenerator(beanNameGenerator);
      beanFactory.registerSingleton(AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR, beanNameGenerator);
View Full Code Here

    // Detect any custom bean name generation strategy supplied through the enclosing application context
    SingletonBeanRegistry singletonRegistry = null;
    if (registry instanceof SingletonBeanRegistry) {
      singletonRegistry = (SingletonBeanRegistry) registry;
      if (!this.localBeanNameGeneratorSet && singletonRegistry.containsSingleton(CONFIGURATION_BEAN_NAME_GENERATOR)) {
        BeanNameGenerator generator = (BeanNameGenerator) singletonRegistry.getSingleton(CONFIGURATION_BEAN_NAME_GENERATOR);
        this.componentScanBeanNameGenerator = generator;
        this.importBeanNameGenerator = generator;
      }
    }
View Full Code Here

    readerContext.fireComponentRegistered(compositeDef);
  }

  protected void parseBeanNameGenerator(Element element, ClassPathBeanDefinitionScanner scanner) {
    if (element.hasAttribute(NAME_GENERATOR_ATTRIBUTE)) {
      BeanNameGenerator beanNameGenerator = (BeanNameGenerator) instantiateUserDefinedStrategy(
          element.getAttribute(NAME_GENERATOR_ATTRIBUTE), BeanNameGenerator.class,
          scanner.getResourceLoader().getClassLoader());
      scanner.setBeanNameGenerator(beanNameGenerator);
    }
  }
View Full Code Here

   */
  @Override
  protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) {
    AnnotatedBeanDefinitionReader reader = new AnnotatedBeanDefinitionReader(beanFactory);
    ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(beanFactory);
    BeanNameGenerator beanNameGenerator = getBeanNameGenerator();
    ScopeMetadataResolver scopeMetadataResolver = getScopeMetadataResolver();
    if (beanNameGenerator != null) {
      reader.setBeanNameGenerator(beanNameGenerator);
      scanner.setBeanNameGenerator(beanNameGenerator);
    }
View Full Code Here

    readerContext.fireComponentRegistered(compositeDef);
  }

  protected void parseBeanNameGenerator(Element element, ClassPathBeanDefinitionScanner scanner) {
    if (element.hasAttribute(NAME_GENERATOR_ATTRIBUTE)) {
      BeanNameGenerator beanNameGenerator = (BeanNameGenerator) instantiateUserDefinedStrategy(
          element.getAttribute(NAME_GENERATOR_ATTRIBUTE), BeanNameGenerator.class,
          scanner.getResourceLoader().getClassLoader());
      scanner.setBeanNameGenerator(beanNameGenerator);
    }
  }
View Full Code Here

    readerContext.fireComponentRegistered(compositeDef);
  }

  protected void parseBeanNameGenerator(ClassPathBeanDefinitionScanner scanner, Element element) {
    if (element.hasAttribute(NAME_GENERATOR_ATTRIBUTE)) {
      BeanNameGenerator beanNameGenerator = (BeanNameGenerator) instantiateUserDefinedStrategy(
          element.getAttribute(NAME_GENERATOR_ATTRIBUTE), BeanNameGenerator.class,
          scanner.getResourceLoader().getClassLoader());
      scanner.setBeanNameGenerator(beanNameGenerator);
    }
  }
View Full Code Here

  @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
View Full Code Here

TOP

Related Classes of org.springframework.beans.factory.support.BeanNameGenerator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.