Package org.springframework.beans.factory.config

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


    lbf.registerBeanDefinition(JUERGEN, person1);
    ConstructorArgumentValues cavs2 = new ConstructorArgumentValues();
    cavs2.addGenericArgumentValue(MARK);
    RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
    lbf.registerBeanDefinition(MARK, person2);
    DependencyDescriptor qualifiedDescriptor = new DependencyDescriptor(
        QualifiedTestBean.class.getDeclaredField("qualified"), false);
    DependencyDescriptor nonqualifiedDescriptor = new DependencyDescriptor(
        QualifiedTestBean.class.getDeclaredField("nonqualified"), false);
    assertTrue(lbf.isAutowireCandidate(JUERGEN, null));
    assertTrue(lbf.isAutowireCandidate(JUERGEN, nonqualifiedDescriptor));
    assertTrue(lbf.isAutowireCandidate(JUERGEN, qualifiedDescriptor));
    assertTrue(lbf.isAutowireCandidate(MARK, null));
View Full Code Here


    cavs.addGenericArgumentValue(JUERGEN);
    RootBeanDefinition person = new RootBeanDefinition(Person.class, cavs, null);
    person.setAutowireCandidate(false);
    person.addQualifier(new AutowireCandidateQualifier(TestQualifier.class));
    lbf.registerBeanDefinition(JUERGEN, person);
    DependencyDescriptor qualifiedDescriptor = new DependencyDescriptor(
        QualifiedTestBean.class.getDeclaredField("qualified"), false);
    DependencyDescriptor nonqualifiedDescriptor = new DependencyDescriptor(
        QualifiedTestBean.class.getDeclaredField("nonqualified"), false);
    assertFalse(lbf.isAutowireCandidate(JUERGEN, null));
    assertFalse(lbf.isAutowireCandidate(JUERGEN, nonqualifiedDescriptor));
    assertFalse(lbf.isAutowireCandidate(JUERGEN, qualifiedDescriptor));
  }
View Full Code Here

    ConstructorArgumentValues cavs = new ConstructorArgumentValues();
    cavs.addGenericArgumentValue(JUERGEN);
    RootBeanDefinition person = new RootBeanDefinition(Person.class, cavs, null);
    person.addQualifier(new AutowireCandidateQualifier(ClassUtils.getShortName(TestQualifier.class)));
    lbf.registerBeanDefinition(JUERGEN, person);
    DependencyDescriptor qualifiedDescriptor = new DependencyDescriptor(
        QualifiedTestBean.class.getDeclaredField("qualified"), false);
    DependencyDescriptor nonqualifiedDescriptor = new DependencyDescriptor(
        QualifiedTestBean.class.getDeclaredField("nonqualified"), false);
    assertTrue(lbf.isAutowireCandidate(JUERGEN, null));
    assertTrue(lbf.isAutowireCandidate(JUERGEN, nonqualifiedDescriptor));
    assertTrue(lbf.isAutowireCandidate(JUERGEN, qualifiedDescriptor));
  }
View Full Code Here

    ConstructorArgumentValues cavs2 = new ConstructorArgumentValues();
    cavs2.addGenericArgumentValue(MARK);
    RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
    lbf.registerBeanDefinition(MARK, person2);
    MethodParameter param = new MethodParameter(QualifiedTestBean.class.getDeclaredConstructor(Person.class), 0);
    DependencyDescriptor qualifiedDescriptor = new DependencyDescriptor(param, false);
    param.initParameterNameDiscovery(new LocalVariableTableParameterNameDiscoverer());
    assertEquals("tpb", param.getParameterName());
    assertTrue(lbf.isAutowireCandidate(JUERGEN, null));
    assertTrue(lbf.isAutowireCandidate(JUERGEN, qualifiedDescriptor));
    assertFalse(lbf.isAutowireCandidate(MARK, qualifiedDescriptor));
View Full Code Here

    lbf.registerBeanDefinition(MARK, person2);
    MethodParameter qualifiedParam =
        new MethodParameter(QualifiedTestBean.class.getDeclaredMethod("autowireQualified", Person.class), 0);
    MethodParameter nonqualifiedParam =
        new MethodParameter(QualifiedTestBean.class.getDeclaredMethod("autowireNonqualified", Person.class), 0);
    DependencyDescriptor qualifiedDescriptor = new DependencyDescriptor(qualifiedParam, false);
    DependencyDescriptor nonqualifiedDescriptor = new DependencyDescriptor(nonqualifiedParam, false);
    qualifiedParam.initParameterNameDiscovery(new LocalVariableTableParameterNameDiscoverer());
    assertEquals("tpb", qualifiedParam.getParameterName());
    nonqualifiedParam.initParameterNameDiscovery(new LocalVariableTableParameterNameDiscoverer());
    assertEquals("tpb", nonqualifiedParam.getParameterName());
    assertTrue(lbf.isAutowireCandidate(JUERGEN, null));
View Full Code Here

    ConstructorArgumentValues cavs2 = new ConstructorArgumentValues();
    cavs2.addGenericArgumentValue(MARK);
    RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
    person2.addQualifier(new AutowireCandidateQualifier(TestQualifier.class));
    lbf.registerBeanDefinition(MARK, person2);
    DependencyDescriptor qualifiedDescriptor = new DependencyDescriptor(
        new MethodParameter(QualifiedTestBean.class.getDeclaredConstructor(Person.class), 0),
        false);
    assertTrue(lbf.isAutowireCandidate(JUERGEN, qualifiedDescriptor));
    assertTrue(lbf.isAutowireCandidate(MARK, qualifiedDescriptor));
  }
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.addPropertyValue(propertyName, autowiredArgument);
        }
View Full Code Here

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

    return this.autowireFactory.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.addPropertyValue(propertyName, autowiredArgument);
        }
View Full Code Here

      Field field = (Field) this.member;
      try {
        Object value = null;
        if (this.cached) {
          if (this.cachedFieldValue instanceof DependencyDescriptor) {
            DependencyDescriptor descriptor = (DependencyDescriptor) this.cachedFieldValue;
            TypeConverter typeConverter = beanFactory.getTypeConverter();
            value = beanFactory.resolveDependency(descriptor, beanName, null, typeConverter);
          }
          else if (this.cachedFieldValue instanceof RuntimeBeanReference) {
            value = beanFactory.getBean(((RuntimeBeanReference) this.cachedFieldValue).getBeanName());
          }
          else {
            value = this.cachedFieldValue;
          }
        }
        else {
          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

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.