Package org.springframework.beans.factory.support

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


        scanner.setMarkerInterface(markerInterface);
      }
      String nameGeneratorClassName = element.getAttribute(ATTRIBUTE_NAME_GENERATOR);
      if (StringUtils.hasText(nameGeneratorClassName)) {
        Class<?> nameGeneratorClass = classLoader.loadClass(nameGeneratorClassName);
        BeanNameGenerator nameGenerator = BeanUtils.instantiateClass(nameGeneratorClass, BeanNameGenerator.class);
        scanner.setBeanNameGenerator(nameGenerator);
      }
    } catch (Exception ex) {
      readerContext.error(ex.getMessage(), readerContext.extractSource(element), ex.getCause());
    }
View Full Code Here


    reader.setEnvironment(this.getEnvironment());

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

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

    reader.setEnvironment(this.getEnvironment());

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

    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

    // 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

      }
    }

    // Register BeanNameGenerator if class name provided.
    if (element.hasAttribute(NAME_GENERATOR_ATTRIBUTE)) {
      BeanNameGenerator beanNameGenerator = (BeanNameGenerator) instantiateUserDefinedStrategy(
          element.getAttribute(NAME_GENERATOR_ATTRIBUTE), BeanNameGenerator.class, resourceLoader.getClassLoader());
      scanner.setBeanNameGenerator(beanNameGenerator);
    }

    // Register ScopeMetadataResolver if class name provided.
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

  private ApplicationContext createContext(ScopedProxyMode scopedProxyMode) {
    GenericWebApplicationContext context = new GenericWebApplicationContext();
    ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context, false);
    scanner.setIncludeAnnotationConfig(false);
    scanner.addIncludeFilter(new AnnotationTypeFilter(ScopeTestComponent.class));
    scanner.setBeanNameGenerator(new BeanNameGenerator() {
      public String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) {
        String beanClassName = ClassUtils.getShortName(definition.getBeanClassName());
        int begin = beanClassName.lastIndexOf('.') + 1;
        int end = beanClassName.lastIndexOf("ScopedTestBean");
        return beanClassName.substring(begin, end).toLowerCase();
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

    private void setupConfigurationClassPostProcessor(final ParserContext parserContext) {
        BeanDefinitionRegistry beanDefinitionRegistry = parserContext.getRegistry();

        BeanDefinitionBuilder configurationClassPostProcessor = BeanDefinitionBuilder.rootBeanDefinition(ConfigurationClassPostProcessor.class);
        BeanNameGenerator beanNameGenerator = parserContext.getReaderContext().getReader().getBeanNameGenerator();
        AbstractBeanDefinition configurationClassPostProcessorBeanDefinition = configurationClassPostProcessor.getBeanDefinition();
        String beanName = beanNameGenerator.generateBeanName(configurationClassPostProcessorBeanDefinition, beanDefinitionRegistry);
        beanDefinitionRegistry.registerBeanDefinition(beanName, configurationClassPostProcessorBeanDefinition);
    }
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.