Package org.springframework.beans.factory.support

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


  private static boolean isQualifierMatch(String qualifier, String beanName, ConfigurableListableBeanFactory bf) {
    if (bf.containsBean(beanName)) {
      try {
        BeanDefinition bd = bf.getMergedBeanDefinition(beanName);
        if (bd instanceof AbstractBeanDefinition) {
          AbstractBeanDefinition abd = (AbstractBeanDefinition) bd;
          AutowireCandidateQualifier candidate = abd.getQualifier(Qualifier.class.getName());
          if ((candidate != null && qualifier.equals(candidate.getAttribute(AutowireCandidateQualifier.VALUE_KEY))) ||
              qualifier.equals(beanName) || ObjectUtils.containsElement(bf.getAliases(beanName), qualifier)) {
            return true;
          }
        }
View Full Code Here


    if (containingBean == null) {
      checkNameUniqueness(beanName, aliases, ele);
    }

    AbstractBeanDefinition beanDefinition = parseBeanDefinitionElement(ele, beanName, containingBean);
    if (beanDefinition != null) {
      if (!StringUtils.hasText(beanName)) {
        try {
          if (containingBean != null) {
            beanName = BeanDefinitionReaderUtils.generateBeanName(
                beanDefinition, this.readerContext.getRegistry(), true);
          }
          else {
            beanName = this.readerContext.generateBeanName(beanDefinition);
            // Register an alias for the plain bean class name, if still possible,
            // if the generator returned the class name plus a suffix.
            // This is expected for Spring 1.2/2.0 backwards compatibility.
            String beanClassName = beanDefinition.getBeanClassName();
            if (beanClassName != null &&
                beanName.startsWith(beanClassName) && beanName.length() > beanClassName.length() &&
                !this.readerContext.getRegistry().isBeanNameInUse(beanClassName)) {
              aliases.add(beanClassName);
            }
View Full Code Here

    try {
      String parent = null;
      if (ele.hasAttribute(PARENT_ATTRIBUTE)) {
        parent = ele.getAttribute(PARENT_ATTRIBUTE);
      }
      AbstractBeanDefinition bd = createBeanDefinition(className, parent);

      parseBeanDefinitionAttributes(ele, beanName, containingBean, bd);
      bd.setDescription(DomUtils.getChildElementValueByTagName(ele, DESCRIPTION_ELEMENT));

      parseMetaElements(ele, bd);
      parseLookupOverrideSubElements(ele, bd.getMethodOverrides());
      parseReplacedMethodSubElements(ele, bd.getMethodOverrides());

      parseConstructorArgElements(ele, bd);
      parsePropertyElements(ele, bd);
      parseQualifierElements(ele, bd);

      bd.setResource(this.readerContext.getResource());
      bd.setSource(extractSource(ele));

      return bd;
    }
    catch (ClassNotFoundException ex) {
      error("Bean class [" + className + "] not found", ele, ex);
View Full Code Here

    if (containingBean == null) {
      checkNameUniqueness(beanName, aliases, ele);
    }

    AbstractBeanDefinition beanDefinition = parseBeanDefinitionElement(ele, beanName, containingBean);
    if (beanDefinition != null) {
      if (!StringUtils.hasText(beanName)) {
        try {
          if (containingBean != null) {
            beanName = BeanDefinitionReaderUtils.generateBeanName(
                beanDefinition, this.readerContext.getRegistry(), true);
          }
          else {
            beanName = this.readerContext.generateBeanName(beanDefinition);
            // Register an alias for the plain bean class name, if still possible,
            // if the generator returned the class name plus a suffix.
            // This is expected for Spring 1.2/2.0 backwards compatibility.
            String beanClassName = beanDefinition.getBeanClassName();
            if (beanClassName != null &&
                beanName.startsWith(beanClassName) && beanName.length() > beanClassName.length() &&
                !this.readerContext.getRegistry().isBeanNameInUse(beanClassName)) {
              aliases.add(beanClassName);
            }
View Full Code Here

    try {
      String parent = null;
      if (ele.hasAttribute(PARENT_ATTRIBUTE)) {
        parent = ele.getAttribute(PARENT_ATTRIBUTE);
      }
      AbstractBeanDefinition bd = createBeanDefinition(className, parent);

      parseBeanDefinitionAttributes(ele, beanName, containingBean, bd);
      bd.setDescription(DomUtils.getChildElementValueByTagName(ele, DESCRIPTION_ELEMENT));

      parseMetaElements(ele, bd);
      parseLookupOverrideSubElements(ele, bd.getMethodOverrides());
      parseReplacedMethodSubElements(ele, bd.getMethodOverrides());

      parseConstructorArgElements(ele, bd);
      parsePropertyElements(ele, bd);
      parseQualifierElements(ele, bd);

      bd.setResource(this.readerContext.getResource());
      bd.setSource(extractSource(ele));

      return bd;
    }
    catch (ClassNotFoundException ex) {
      error("Bean class [" + className + "] not found", ele, ex);
View Full Code Here

      String setterName = "set" + StringUtils.capitalize(propertyName);
      Signature signature = new Signature(setterName, Type.VOID_TYPE, new Type[] {Type.getType(propertyType)});
      maker.add(signature, new Type[0]);
    }
    if (bd instanceof AbstractBeanDefinition) {
      AbstractBeanDefinition abd = (AbstractBeanDefinition) bd;
      if (abd.getInitMethodName() != null) {
        Signature signature = new Signature(abd.getInitMethodName(), Type.VOID_TYPE, new Type[0]);
        maker.add(signature, new Type[0]);
      }
      if (abd.getDestroyMethodName() != null) {
        Signature signature = new Signature(abd.getDestroyMethodName(), Type.VOID_TYPE, new Type[0]);
        maker.add(signature, new Type[0]);
      }
    }
    return maker.create();
  }
View Full Code Here

    String serverBeanName = element.getAttribute(SERVER_ATTRIBUTE);
    if (StringUtils.hasText(serverBeanName)) {
      builder.addPropertyReference("server", serverBeanName);
    }
    else {
      AbstractBeanDefinition specialServer = MBeanServerBeanDefinitionParser.findServerForSpecialEnvironment();
      if (specialServer != null) {
        builder.addPropertyValue("server", specialServer);
      }
    }
    return builder.getBeanDefinition();
View Full Code Here

          "Either add CGLIB to the classpath or remove the following @Configuration bean definitions: " +
          configBeanDefs.keySet());
    }
    ConfigurationClassEnhancer enhancer = new ConfigurationClassEnhancer(beanFactory);
    for (Map.Entry<String, AbstractBeanDefinition> entry : configBeanDefs.entrySet()) {
      AbstractBeanDefinition beanDef = entry.getValue();
      try {
        Class<?> configClass = beanDef.resolveBeanClass(this.beanClassLoader);
        Class<?> enhancedClass = enhancer.enhance(configClass);
        if (configClass != enhancedClass) {
          if (logger.isDebugEnabled()) {
            logger.debug(String.format("Replacing bean definition '%s' existing class name '%s' " +
                "with enhanced class name '%s'", entry.getKey(), configClass.getName(), enhancedClass.getName()));
          }
          beanDef.setBeanClass(enhancedClass);
        }
      }
      catch (Throwable ex) {
        throw new IllegalStateException("Cannot load configuration class: " + beanDef.getBeanClassName(), ex);
      }
    }
  }
View Full Code Here

  private static boolean isQualifierMatch(String qualifier, String beanName, ConfigurableListableBeanFactory bf) {
    if (bf.containsBean(beanName)) {
      try {
        BeanDefinition bd = bf.getMergedBeanDefinition(beanName);
        if (bd instanceof AbstractBeanDefinition) {
          AbstractBeanDefinition abd = (AbstractBeanDefinition) bd;
          AutowireCandidateQualifier candidate = abd.getQualifier(Qualifier.class.getName());
          if ((candidate != null && qualifier.equals(candidate.getAttribute(AutowireCandidateQualifier.VALUE_KEY))) ||
              qualifier.equals(beanName) || ObjectUtils.containsElement(bf.getAliases(beanName), qualifier)) {
            return true;
          }
        }
View Full Code Here

    if (containingBean == null) {
      checkNameUniqueness(beanName, aliases, ele);
    }

    AbstractBeanDefinition beanDefinition = parseBeanDefinitionElement(ele, beanName, containingBean);
    if (beanDefinition != null) {
      if (!StringUtils.hasText(beanName)) {
        try {
          if (containingBean != null) {
            beanName = BeanDefinitionReaderUtils.generateBeanName(
                beanDefinition, this.readerContext.getRegistry(), true);
          }
          else {
            beanName = this.readerContext.generateBeanName(beanDefinition);
            // Register an alias for the plain bean class name, if still possible,
            // if the generator returned the class name plus a suffix.
            // This is expected for Spring 1.2/2.0 backwards compatibility.
            String beanClassName = beanDefinition.getBeanClassName();
            if (beanClassName != null &&
                beanName.startsWith(beanClassName) && beanName.length() > beanClassName.length() &&
                !this.readerContext.getRegistry().isBeanNameInUse(beanClassName)) {
              aliases.add(beanClassName);
            }
View Full Code Here

TOP

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

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.