Package org.springframework.beans

Examples of org.springframework.beans.TypeConverter.convertIfNecessary()


        BeanDefinition bd = (beanName != null && containsBean(beanName) ? getMergedBeanDefinition(beanName) : null);
        value = evaluateBeanDefinitionString(strVal, bd);
      }
      TypeConverter converter = (typeConverter != null ? typeConverter : getTypeConverter());
      return (descriptor.getField() != null ?
          converter.convertIfNecessary(value, type, descriptor.getField()) :
          converter.convertIfNecessary(value, type, descriptor.getMethodParameter()));
    }

    if (type.isArray()) {
      Class<?> componentType = type.getComponentType();
View Full Code Here


        value = evaluateBeanDefinitionString(strVal, bd);
      }
      TypeConverter converter = (typeConverter != null ? typeConverter : getTypeConverter());
      return (descriptor.getField() != null ?
          converter.convertIfNecessary(value, type, descriptor.getField()) :
          converter.convertIfNecessary(value, type, descriptor.getMethodParameter()));
    }

    if (type.isArray()) {
      Class<?> componentType = type.getComponentType();
      DependencyDescriptor targetDesc = new DependencyDescriptor(descriptor);
View Full Code Here

      }
      if (autowiredBeanNames != null) {
        autowiredBeanNames.addAll(matchingBeans.keySet());
      }
      TypeConverter converter = (typeConverter != null ? typeConverter : getTypeConverter());
      Object result = converter.convertIfNecessary(matchingBeans.values(), type);
      if (getDependencyComparator() != null && result instanceof Object[]) {
        Arrays.sort((Object[]) result, adaptDependencyComparator(matchingBeans));
      }
      return result;
    }
View Full Code Here

      }
      if (autowiredBeanNames != null) {
        autowiredBeanNames.addAll(matchingBeans.keySet());
      }
      TypeConverter converter = (typeConverter != null ? typeConverter : getTypeConverter());
      Object result = converter.convertIfNecessary(matchingBeans.values(), type);
      if (getDependencyComparator() != null && result instanceof List) {
        Collections.sort((List<?>) result, adaptDependencyComparator(matchingBeans));
      }
      return result;
    }
View Full Code Here

      if (value instanceof String) {
        String strVal = resolveEmbeddedValue((String) value);
        value = evaluateBeanDefinitionString(strVal, getMergedBeanDefinition(beanName));
      }
      TypeConverter converter = (typeConverter != null ? typeConverter : getTypeConverter());
      return converter.convertIfNecessary(value, type);
    }

    if (type.isArray()) {
      Class componentType = type.getComponentType();
      Map<String, Object> matchingBeans = findAutowireCandidates(beanName, componentType, descriptor);
View Full Code Here

      }
      if (autowiredBeanNames != null) {
        autowiredBeanNames.addAll(matchingBeans.keySet());
      }
      TypeConverter converter = (typeConverter != null ? typeConverter : getTypeConverter());
      return converter.convertIfNecessary(matchingBeans.values(), type);
    }
    else if (Collection.class.isAssignableFrom(type) && type.isInterface()) {
      Class elementType = descriptor.getCollectionType();
      if (elementType == null) {
        if (descriptor.isRequired()) {
View Full Code Here

      }
      if (autowiredBeanNames != null) {
        autowiredBeanNames.addAll(matchingBeans.keySet());
      }
      TypeConverter converter = (typeConverter != null ? typeConverter : getTypeConverter());
      return converter.convertIfNecessary(matchingBeans.values(), type);
    }
    else if (Map.class.isAssignableFrom(type) && type.isInterface()) {
      Class keyType = descriptor.getMapKeyType();
      if (keyType == null || !String.class.isAssignableFrom(keyType)) {
        if (descriptor.isRequired()) {
View Full Code Here

          convertedValue = valueHolder.getConvertedValue();
          args.preparedArguments[paramIndex] = convertedValue;
        }
        else {
          try {
            convertedValue = converter.convertIfNecessary(originalValue, paramType,
                MethodParameter.forMethodOrConstructor(methodOrCtor, paramIndex));
            if (originalValue == sourceValue || sourceValue instanceof TypedStringValue) {
              // Either a converted value or still the original one: store converted value.
              sourceHolder.setConvertedValue(convertedValue);
              args.preparedArguments[paramIndex] = convertedValue;
View Full Code Here

      else if (argValue instanceof String) {
        argValue = this.beanFactory.evaluateBeanDefinitionString((String) argValue, mbd);
      }
      Class<?> paramType = paramTypes[argIndex];
      try {
        resolvedArgs[argIndex] = converter.convertIfNecessary(argValue, paramType, methodParam);
      }
      catch (TypeMismatchException ex) {
        String methodType = (methodOrCtor instanceof Constructor ? "constructor" : "factory method");
        throw new UnsatisfiedDependencyException(
            mbd.getResourceDescription(), beanName, argIndex, paramType,
View Full Code Here

        else {
          ConstructorArgumentValues.ValueHolder sourceHolder =
              (ConstructorArgumentValues.ValueHolder) valueHolder.getSource();
          Object sourceValue = sourceHolder.getValue();
          try {
            convertedValue = converter.convertIfNecessary(originalValue, paramType,
                MethodParameter.forMethodOrConstructor(methodOrCtor, paramIndex));
            // TODO re-enable once race condition has been found (SPR-7423)
            /*
            if (originalValue == sourceValue || sourceValue instanceof TypedStringValue) {
              // Either a converted value or still the original one: store converted value.
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.