Package org.springframework.beans.factory.config

Examples of org.springframework.beans.factory.config.ConstructorArgumentValues


    setFactoryMethodName(original.getFactoryMethodName());
    setScope(original.getScope());
    setAbstract(original.isAbstract());
    setLazyInit(original.isLazyInit());
    setRole(original.getRole());
    setConstructorArgumentValues(new ConstructorArgumentValues(original.getConstructorArgumentValues()));
    setPropertyValues(new MutablePropertyValues(original.getPropertyValues()));
    setSource(original.getSource());
    copyAttributesFrom(original);

    if (original instanceof AbstractBeanDefinition) {
View Full Code Here


  /**
   * Specify constructor argument values for this bean.
   */
  public void setConstructorArgumentValues(ConstructorArgumentValues constructorArgumentValues) {
    this.constructorArgumentValues =
        (constructorArgumentValues != null ? constructorArgumentValues : new ConstructorArgumentValues());
  }
View Full Code Here

    if (constructorToUse == null) {
      // Need to resolve the constructor.
      boolean autowiring = (chosenCtors != null ||
          mbd.getResolvedAutowireMode() == RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
      ConstructorArgumentValues resolvedValues = null;

      int minNrOfArgs;
      if (explicitArgs != null) {
        minNrOfArgs = explicitArgs.length;
      }
      else {
        ConstructorArgumentValues cargs = mbd.getConstructorArgumentValues();
        resolvedValues = new ConstructorArgumentValues();
        minNrOfArgs = resolveConstructorArguments(beanName, mbd, bw, cargs, resolvedValues);
      }

      // Take specified constructors, if any.
      Constructor[] candidates = chosenCtors;
View Full Code Here

        }
      }
      Method[] candidates = candidateSet.toArray(new Method[candidateSet.size()]);
      AutowireUtils.sortFactoryMethods(candidates);

      ConstructorArgumentValues resolvedValues = null;
      boolean autowiring = (mbd.getResolvedAutowireMode() == RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
      int minTypeDiffWeight = Integer.MAX_VALUE;
      Set<Method> ambiguousFactoryMethods = null;

      int minNrOfArgs;
      if (explicitArgs != null) {
        minNrOfArgs = explicitArgs.length;
      }
      else {
        // We don't have arguments passed in programmatically, so we need to resolve the
        // arguments specified in the constructor arguments held in the bean definition.
        ConstructorArgumentValues cargs = mbd.getConstructorArgumentValues();
        resolvedValues = new ConstructorArgumentValues();
        minNrOfArgs = resolveConstructorArguments(beanName, mbd, bw, cargs, resolvedValues);
      }

      List<Exception> causes = null;
View Full Code Here

    setFactoryMethodName(original.getFactoryMethodName());
    setScope(original.getScope());
    setAbstract(original.isAbstract());
    setLazyInit(original.isLazyInit());
    setRole(original.getRole());
    setConstructorArgumentValues(new ConstructorArgumentValues(original.getConstructorArgumentValues()));
    setPropertyValues(new MutablePropertyValues(original.getPropertyValues()));
    setSource(original.getSource());
    copyAttributesFrom(original);

    if (original instanceof AbstractBeanDefinition) {
View Full Code Here

  /**
   * Specify constructor argument values for this bean.
   */
  public void setConstructorArgumentValues(ConstructorArgumentValues constructorArgumentValues) {
    this.constructorArgumentValues =
        (constructorArgumentValues != null ? constructorArgumentValues : new ConstructorArgumentValues());
  }
View Full Code Here

    String parent = null;
    String scope = GenericBeanDefinition.SCOPE_SINGLETON;
    boolean isAbstract = false;
    boolean lazyInit = false;

    ConstructorArgumentValues cas = new ConstructorArgumentValues();
    MutablePropertyValues pvs = new MutablePropertyValues();

    for (Map.Entry entry : map.entrySet()) {
      String key = StringUtils.trimWhitespace((String) entry.getKey());
      if (key.startsWith(prefix + SEPARATOR)) {
        String property = key.substring(prefix.length() + SEPARATOR.length());
        if (CLASS_KEY.equals(property)) {
          className = StringUtils.trimWhitespace((String) entry.getValue());
        }
        else if (PARENT_KEY.equals(property)) {
          parent = StringUtils.trimWhitespace((String) entry.getValue());
        }
        else if (ABSTRACT_KEY.equals(property)) {
          String val = StringUtils.trimWhitespace((String) entry.getValue());
          isAbstract = TRUE_VALUE.equals(val);
        }
        else if (SCOPE_KEY.equals(property)) {
          // Spring 2.0 style
          scope = StringUtils.trimWhitespace((String) entry.getValue());
        }
        else if (SINGLETON_KEY.equals(property)) {
          // Spring 1.2 style
          String val = StringUtils.trimWhitespace((String) entry.getValue());
          scope = ((val == null || TRUE_VALUE.equals(val) ? GenericBeanDefinition.SCOPE_SINGLETON :
              GenericBeanDefinition.SCOPE_PROTOTYPE));
        }
        else if (LAZY_INIT_KEY.equals(property)) {
          String val = StringUtils.trimWhitespace((String) entry.getValue());
          lazyInit = TRUE_VALUE.equals(val);
        }
        else if (property.startsWith(CONSTRUCTOR_ARG_PREFIX)) {
          if (property.endsWith(REF_SUFFIX)) {
            int index = Integer.parseInt(property.substring(1, property.length() - REF_SUFFIX.length()));
            cas.addIndexedArgumentValue(index, new RuntimeBeanReference(entry.getValue().toString()));
          }
          else {
            int index = Integer.parseInt(property.substring(1));
            cas.addIndexedArgumentValue(index, readValue(entry));
          }
        }
        else if (property.endsWith(REF_SUFFIX)) {
          // This isn't a real property, but a reference to another prototype
          // Extract property name: property is of form dog(ref)
View Full Code Here

    setFactoryMethodName(original.getFactoryMethodName());
    setScope(original.getScope());
    setAbstract(original.isAbstract());
    setLazyInit(original.isLazyInit());
    setRole(original.getRole());
    setConstructorArgumentValues(new ConstructorArgumentValues(original.getConstructorArgumentValues()));
    setPropertyValues(new MutablePropertyValues(original.getPropertyValues()));
    setSource(original.getSource());
    copyAttributesFrom(original);

    if (original instanceof AbstractBeanDefinition) {
View Full Code Here

  /**
   * Specify constructor argument values for this bean.
   */
  public void setConstructorArgumentValues(ConstructorArgumentValues constructorArgumentValues) {
    this.constructorArgumentValues =
        (constructorArgumentValues != null ? constructorArgumentValues : new ConstructorArgumentValues());
  }
View Full Code Here

      Boolean flag = new Boolean(proxyTargetClass);
      bd.setAttribute(ScriptFactoryPostProcessor.PROXY_TARGET_CLASS_ATTRIBUTE, flag);
    }

    // Add constructor arguments.
    ConstructorArgumentValues cav = bd.getConstructorArgumentValues();
    int constructorArgNum = 0;
    cav.addIndexedArgumentValue(constructorArgNum++, value);
    if (element.hasAttribute(SCRIPT_INTERFACES_ATTRIBUTE)) {
      cav.addIndexedArgumentValue(constructorArgNum++, element.getAttribute(SCRIPT_INTERFACES_ATTRIBUTE));
    }

    // This is used for Groovy. It's a bean reference to a customizer bean.
    if (element.hasAttribute(CUSTOMIZER_REF_ATTRIBUTE)) {
      String customizerBeanName = element.getAttribute(CUSTOMIZER_REF_ATTRIBUTE);
      if (!StringUtils.hasText(customizerBeanName)) {
        parserContext.getReaderContext().error("Attribute 'customizer-ref' has empty value", element);
      }
      else {
        cav.addIndexedArgumentValue(constructorArgNum++, new RuntimeBeanReference(customizerBeanName));
      }
    }

    // Add any property definitions that need adding.
    parserContext.getDelegate().parsePropertyElements(element, bd);
View Full Code Here

TOP

Related Classes of org.springframework.beans.factory.config.ConstructorArgumentValues

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.