Search in sources :

Example 6 with SimpleTypeConverter

use of org.springframework.beans.SimpleTypeConverter in project spring-framework by spring-projects.

the class QualifierAnnotationAutowireCandidateResolver method checkQualifiers.

/**
 * Match the given qualifier annotations against the candidate bean definition.
 */
protected boolean checkQualifiers(BeanDefinitionHolder bdHolder, Annotation[] annotationsToSearch) {
    if (ObjectUtils.isEmpty(annotationsToSearch)) {
        return true;
    }
    SimpleTypeConverter typeConverter = new SimpleTypeConverter();
    for (Annotation annotation : annotationsToSearch) {
        Class<? extends Annotation> type = annotation.annotationType();
        boolean checkMeta = true;
        boolean fallbackToMeta = false;
        if (isQualifier(type)) {
            if (!checkQualifier(bdHolder, annotation, typeConverter)) {
                fallbackToMeta = true;
            } else {
                checkMeta = false;
            }
        }
        if (checkMeta) {
            boolean foundMeta = false;
            for (Annotation metaAnn : type.getAnnotations()) {
                Class<? extends Annotation> metaType = metaAnn.annotationType();
                if (isQualifier(metaType)) {
                    foundMeta = true;
                    // Otherwise it is just a marker for a custom qualifier annotation.
                    if ((fallbackToMeta && ObjectUtils.isEmpty(AnnotationUtils.getValue(metaAnn))) || !checkQualifier(bdHolder, metaAnn, typeConverter)) {
                        return false;
                    }
                }
            }
            if (fallbackToMeta && !foundMeta) {
                return false;
            }
        }
    }
    return true;
}
Also used : SimpleTypeConverter(org.springframework.beans.SimpleTypeConverter) Annotation(java.lang.annotation.Annotation)

Aggregations

SimpleTypeConverter (org.springframework.beans.SimpleTypeConverter)6 MutablePropertyValues (org.springframework.beans.MutablePropertyValues)2 PropertyValue (org.springframework.beans.PropertyValue)2 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)2 GenericBeanDefinition (org.springframework.beans.factory.support.GenericBeanDefinition)2 PathNotFoundException (com.jayway.jsonpath.PathNotFoundException)1 BeanReference (com.revolsys.spring.BeanReference)1 Parameter (com.revolsys.spring.factory.Parameter)1 Annotation (java.lang.annotation.Annotation)1 ExecutorService (java.util.concurrent.ExecutorService)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Matcher (java.util.regex.Matcher)1 Test (org.junit.Test)1 BeansException (org.springframework.beans.BeansException)1 TypeConverter (org.springframework.beans.TypeConverter)1 BeanInitializationException (org.springframework.beans.factory.BeanInitializationException)1 ConfigurableBeanFactory (org.springframework.beans.factory.config.ConfigurableBeanFactory)1 ConversionService (org.springframework.core.convert.ConversionService)1 TypeDescriptor (org.springframework.core.convert.TypeDescriptor)1