Package org.springframework.beans.factory.config

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


          Set<String> autowiredBeanNames = new LinkedHashSet<String>(paramTypes.length);
          TypeConverter typeConverter = beanFactory.getTypeConverter();
          for (int i = 0; i < arguments.length; i++) {
            MethodParameter methodParam = new MethodParameter(method, i);
            GenericTypeResolver.resolveParameterType(methodParam, bean.getClass());
            descriptors[i] = new DependencyDescriptor(methodParam, this.required);
            arguments[i] = beanFactory.resolveDependency(
                descriptors[i], beanName, autowiredBeanNames, typeConverter);
            if (arguments[i] == null && !this.required) {
              arguments = null;
              break;
View Full Code Here


        // even if it technically is a unsatisfied, non-simple property.
        if (!Object.class.equals(pd.getPropertyType())) {
          MethodParameter methodParam = BeanUtils.getWriteMethodParameter(pd);
          // Do not allow eager init for type matching in case of a prioritized post-processor.
          boolean eager = !PriorityOrdered.class.isAssignableFrom(bw.getWrappedClass());
          DependencyDescriptor desc = new AutowireByTypeDependencyDescriptor(methodParam, eager);
          Object autowiredArgument = resolveDependency(desc, beanName, autowiredBeanNames, converter);
          if (autowiredArgument != null) {
            pvs.add(propertyName, autowiredArgument);
          }
          for (String autowiredBeanName : autowiredBeanNames) {
View Full Code Here

          }
          else {
            Set<String> autowiredBeanNames = new LinkedHashSet<String>(4);
            TypeConverter typeConverter = beanFactory.getTypeConverter();
            argument = beanFactory.resolveDependency(
                new DependencyDescriptor(field, this.required),
                beanName, autowiredBeanNames, typeConverter);
            registerDependentBeans(beanName, autowiredBeanNames);
            if (autowiredBeanNames.size() == 1) {
              this.beanNameForField = autowiredBeanNames.iterator().next();
            }
          }
          if (argument != null) {
            ReflectionUtils.makeAccessible(field);
            field.set(bean, argument);
          }
        }
        catch (Throwable ex) {
          throw new BeanCreationException("Could not autowire field: " + field, ex);
        }
      }
      else {
        if (this.pd != null && pvs != null && pvs.contains(this.pd.getName())) {
          // Explicit value provided as part of the bean definition.
          this.skip = true;
          return;
        }
        Method method = (Method) this.member;
        Object[] arguments = new Object[method.getParameterTypes().length];
        try {
          String[] determinedBeanNames = this.beanNamesForMethod;
          if (determinedBeanNames != null) {
            for (int i = 0; i < determinedBeanNames.length; i++) {
              arguments[i] = beanFactory.getBean(determinedBeanNames[i]);
            }
          }
          else {
            Set<String> autowiredBeanNames = new LinkedHashSet<String>(4);
            TypeConverter typeConverter = beanFactory.getTypeConverter();
            for (int i = 0; i < arguments.length; i++) {
              arguments[i] = beanFactory.resolveDependency(
                  new DependencyDescriptor(new MethodParameter(method, i), this.required),
                  beanName, autowiredBeanNames, typeConverter);
              if (arguments[i] == null) {
                arguments = null;
                break;
              }
View Full Code Here

  /**
   * Resolve the specified cached method argument or field value.
   */
  private Object resolvedCachedArgument(String beanName, Object cachedArgument) {
    if (cachedArgument instanceof DependencyDescriptor) {
      DependencyDescriptor descriptor = (DependencyDescriptor) cachedArgument;
      TypeConverter typeConverter = beanFactory.getTypeConverter();
      return beanFactory.resolveDependency(descriptor, beanName, null, typeConverter);
    }
    else if (cachedArgument instanceof RuntimeBeanReference) {
      return beanFactory.getBean(((RuntimeBeanReference) cachedArgument).getBeanName());
View Full Code Here

        else {
          synchronized (this) {
            if (!this.cached) {
              Set<String> autowiredBeanNames = new LinkedHashSet<String>(1);
              TypeConverter typeConverter = beanFactory.getTypeConverter();
              DependencyDescriptor descriptor = new DependencyDescriptor(field, this.required);
              this.cachedFieldValue = descriptor;
              value = beanFactory.resolveDependency(descriptor, beanName, autowiredBeanNames, typeConverter);
              if (value != null) {
                registerDependentBeans(beanName, autowiredBeanNames);
                if (autowiredBeanNames.size() == 1) {
View Full Code Here

              TypeConverter typeConverter = beanFactory.getTypeConverter();
              this.cachedMethodArguments = new Object[arguments.length];
              for (int i = 0; i < arguments.length; i++) {
                MethodParameter methodParam = new MethodParameter(method, i);
                GenericTypeResolver.resolveParameterType(methodParam, bean.getClass());
                DependencyDescriptor descriptor = new DependencyDescriptor(methodParam, this.required);
                this.cachedMethodArguments[i] = descriptor;
                arguments[i] = beanFactory.resolveDependency(
                    descriptor, beanName, autowiredBeanNames, typeConverter);
                if (arguments[i] == null) {
                  arguments = null;
View Full Code Here

   */
  protected Object resolveAutowiredArgument(
      MethodParameter param, String beanName, Set<String> autowiredBeanNames, TypeConverter typeConverter) {

    return this.beanFactory.resolveDependency(
        new DependencyDescriptor(param, true), beanName, autowiredBeanNames, typeConverter);
  }
View Full Code Here

      try {
        PropertyDescriptor pd = bw.getPropertyDescriptor(propertyName);
        MethodParameter methodParam = BeanUtils.getWriteMethodParameter(pd);
        // Do not allow eager init for type matching in case of a prioritized post-processor.
        boolean eager = !PriorityOrdered.class.isAssignableFrom(bw.getWrappedClass());
        DependencyDescriptor desc = new DependencyDescriptor(methodParam, false, eager);

        Object autowiredArgument = resolveDependency(desc, beanName, autowiredBeanNames, converter);
        if (autowiredArgument != null) {
          pvs.add(propertyName, autowiredArgument);
        }
View Full Code Here

    cavs.addGenericArgumentValue(JUERGEN);
    RootBeanDefinition rbd = new RootBeanDefinition(Person.class, cavs, null);
    lbf.registerBeanDefinition(JUERGEN, rbd);
    assertTrue(lbf.isAutowireCandidate(JUERGEN, null));
    assertTrue(lbf.isAutowireCandidate(JUERGEN,
        new DependencyDescriptor(Person.class.getDeclaredField("name"), false)));
    assertTrue(lbf.isAutowireCandidate(JUERGEN,
        new DependencyDescriptor(Person.class.getDeclaredField("name"), true)));
  }
View Full Code Here

    RootBeanDefinition rbd = new RootBeanDefinition(Person.class, cavs, null);
    rbd.setAutowireCandidate(false);
    lbf.registerBeanDefinition(JUERGEN, rbd);
    assertFalse(lbf.isAutowireCandidate(JUERGEN, null));
    assertFalse(lbf.isAutowireCandidate(JUERGEN,
        new DependencyDescriptor(Person.class.getDeclaredField("name"), false)));
    assertFalse(lbf.isAutowireCandidate(JUERGEN,
        new DependencyDescriptor(Person.class.getDeclaredField("name"), true)));
  }
View Full Code Here

TOP

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

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.