Tabnine Logo
QualifierAnnotationAutowireCandidateResolver
Code IndexAdd Tabnine to your IDE (free)

How to use
QualifierAnnotationAutowireCandidateResolver
in
org.springframework.beans.factory.annotation

Best Java code snippets using org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver (Showing top 20 results out of 315)

origin: spring-projects/spring-framework

dlbf.setAutowireCandidateResolver(new QualifierAnnotationAutowireCandidateResolver());
      "Qualifier type [" + customType.getName() + "] needs to be annotation type");
resolver.addQualifierType(customType);
origin: spring-projects/spring-framework

boolean checkMeta = true;
boolean fallbackToMeta = false;
if (isQualifier(type)) {
  if (!checkQualifier(bdHolder, annotation, typeConverter)) {
    fallbackToMeta = true;
  for (Annotation metaAnn : type.getAnnotations()) {
    Class<? extends Annotation> metaType = metaAnn.annotationType();
    if (isQualifier(metaType)) {
      foundMeta = true;
          !checkQualifier(bdHolder, metaAnn, typeConverter)) {
        return false;
origin: spring-projects/spring-framework

/**
 * Determine whether the provided bean definition is an autowire candidate.
 * <p>To be considered a candidate the bean's <em>autowire-candidate</em>
 * attribute must not have been set to 'false'. Also, if an annotation on
 * the field or parameter to be autowired is recognized by this bean factory
 * as a <em>qualifier</em>, the bean must 'match' against the annotation as
 * well as any attributes it may contain. The bean definition must contain
 * the same qualifier or match by meta attributes. A "value" attribute will
 * fallback to match against the bean name or an alias if a qualifier or
 * attribute does not match.
 * @see Qualifier
 */
@Override
public boolean isAutowireCandidate(BeanDefinitionHolder bdHolder, DependencyDescriptor descriptor) {
  boolean match = super.isAutowireCandidate(bdHolder, descriptor);
  if (match) {
    match = checkQualifiers(bdHolder, descriptor.getAnnotations());
    if (match) {
      MethodParameter methodParam = descriptor.getMethodParameter();
      if (methodParam != null) {
        Method method = methodParam.getMethod();
        if (method == null || void.class == method.getReturnType()) {
          match = checkQualifiers(bdHolder, methodParam.getMethodAnnotations());
        }
      }
    }
  }
  return match;
}
origin: spring-projects/spring-framework

@Before
public void setup() {
  QualifierAnnotationAutowireCandidateResolver acr = new QualifierAnnotationAutowireCandidateResolver();
  acr.setBeanFactory(this.beanFactory);
  this.beanFactory.setAutowireCandidateResolver(acr);
}
origin: spring-projects/spring-framework

@Before
public void setup() {
  bf = new DefaultListableBeanFactory();
  bf.registerResolvableDependency(BeanFactory.class, bf);
  bpp = new AutowiredAnnotationBeanPostProcessor();
  bpp.setBeanFactory(bf);
  bf.addBeanPostProcessor(bpp);
  bf.setAutowireCandidateResolver(new QualifierAnnotationAutowireCandidateResolver());
}
origin: spring-projects/spring-framework

Annotation targetAnnotation = getQualifiedElementAnnotation(bd, type);
  targetAnnotation = getFactoryMethodAnnotation(bd, type);
  RootBeanDefinition dbd = getResolvedDecoratedDefinition(bd);
  if (dbd != null) {
    targetAnnotation = getFactoryMethodAnnotation(dbd, type);
  if (getBeanFactory() != null) {
    try {
      Class<?> beanType = getBeanFactory().getType(bdHolder.getBeanName());
      if (beanType != null) {
        targetAnnotation = AnnotationUtils.getAnnotation(ClassUtils.getUserClass(beanType), type);
origin: spring-projects/spring-framework

/**
 * Determine whether the given dependency declares a qualifier annotation.
 * @see #isQualifier(Class)
 * @see Qualifier
 */
@Override
public boolean hasQualifier(DependencyDescriptor descriptor) {
  for (Annotation ann : descriptor.getAnnotations()) {
    if (isQualifier(ann.annotationType())) {
      return true;
    }
  }
  return false;
}
origin: spring-projects/spring-framework

@Test
public void testQualifiedByAttributesWithCustomQualifierRegistered() {
  StaticApplicationContext context = new StaticApplicationContext();
  BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
  reader.loadBeanDefinitions(CONFIG_LOCATION);
  QualifierAnnotationAutowireCandidateResolver resolver = (QualifierAnnotationAutowireCandidateResolver)
      context.getDefaultListableBeanFactory().getAutowireCandidateResolver();
  resolver.addQualifierType(MultipleAttributeQualifier.class);
  context.registerSingleton("testBean", MultiQualifierClient.class);
  context.refresh();
  MultiQualifierClient testBean = (MultiQualifierClient) context.getBean("testBean");
  assertNotNull( testBean.factoryTheta);
  assertNotNull( testBean.implTheta);
}
origin: spring-projects/spring-framework

/**
 * Determine a suggested value from any of the given candidate annotations.
 */
@Nullable
protected Object findValue(Annotation[] annotationsToSearch) {
  if (annotationsToSearch.length > 0) {   // qualifier annotations have to be local
    AnnotationAttributes attr = AnnotatedElementUtils.getMergedAnnotationAttributes(
        AnnotatedElementUtils.forAnnotations(annotationsToSearch), this.valueAnnotationType);
    if (attr != null) {
      return extractValue(attr);
    }
  }
  return null;
}
origin: spring-projects/spring-framework

/**
 * Determine whether the given dependency declares a value annotation.
 * @see Value
 */
@Override
@Nullable
public Object getSuggestedValue(DependencyDescriptor descriptor) {
  Object value = findValue(descriptor.getAnnotations());
  if (value == null) {
    MethodParameter methodParam = descriptor.getMethodParameter();
    if (methodParam != null) {
      value = findValue(methodParam.getMethodAnnotations());
    }
  }
  return value;
}
origin: spring-projects/spring-framework

@Before
public void setup() {
  bf = new DefaultListableBeanFactory();
  bf.registerResolvableDependency(BeanFactory.class, bf);
  bpp = new AutowiredAnnotationBeanPostProcessor();
  bpp.setBeanFactory(bf);
  bf.addBeanPostProcessor(bpp);
  bf.setAutowireCandidateResolver(new QualifierAnnotationAutowireCandidateResolver());
  bf.setDependencyComparator(AnnotationAwareOrderComparator.INSTANCE);
}
origin: org.springframework/spring-beans

Annotation targetAnnotation = getQualifiedElementAnnotation(bd, type);
  targetAnnotation = getFactoryMethodAnnotation(bd, type);
  RootBeanDefinition dbd = getResolvedDecoratedDefinition(bd);
  if (dbd != null) {
    targetAnnotation = getFactoryMethodAnnotation(dbd, type);
  if (getBeanFactory() != null) {
    try {
      Class<?> beanType = getBeanFactory().getType(bdHolder.getBeanName());
      if (beanType != null) {
        targetAnnotation = AnnotationUtils.getAnnotation(ClassUtils.getUserClass(beanType), type);
origin: org.springframework/spring-beans

/**
 * Determine whether the given dependency declares a qualifier annotation.
 * @see #isQualifier(Class)
 * @see Qualifier
 */
@Override
public boolean hasQualifier(DependencyDescriptor descriptor) {
  for (Annotation ann : descriptor.getAnnotations()) {
    if (isQualifier(ann.annotationType())) {
      return true;
    }
  }
  return false;
}
origin: org.springframework/spring-beans

/**
 * Determine a suggested value from any of the given candidate annotations.
 */
@Nullable
protected Object findValue(Annotation[] annotationsToSearch) {
  if (annotationsToSearch.length > 0) {   // qualifier annotations have to be local
    AnnotationAttributes attr = AnnotatedElementUtils.getMergedAnnotationAttributes(
        AnnotatedElementUtils.forAnnotations(annotationsToSearch), this.valueAnnotationType);
    if (attr != null) {
      return extractValue(attr);
    }
  }
  return null;
}
origin: org.springframework/spring-beans

/**
 * Determine whether the given dependency declares a value annotation.
 * @see Value
 */
@Override
@Nullable
public Object getSuggestedValue(DependencyDescriptor descriptor) {
  Object value = findValue(descriptor.getAnnotations());
  if (value == null) {
    MethodParameter methodParam = descriptor.getMethodParameter();
    if (methodParam != null) {
      value = findValue(methodParam.getMethodAnnotations());
    }
  }
  return value;
}
origin: org.springframework/spring-beans

dlbf.setAutowireCandidateResolver(new QualifierAnnotationAutowireCandidateResolver());
      "Qualifier type [" + customType.getName() + "] needs to be annotation type");
resolver.addQualifierType(customType);
origin: stackoverflow.com

beanFactory.setAutowireCandidateResolver(new QualifierAnnotationAutowireCandidateResolver());
origin: apache/servicemix-bundles

Annotation targetAnnotation = getQualifiedElementAnnotation(bd, type);
  targetAnnotation = getFactoryMethodAnnotation(bd, type);
  RootBeanDefinition dbd = getResolvedDecoratedDefinition(bd);
  if (dbd != null) {
    targetAnnotation = getFactoryMethodAnnotation(dbd, type);
  if (getBeanFactory() != null) {
    try {
      Class<?> beanType = getBeanFactory().getType(bdHolder.getBeanName());
      if (beanType != null) {
        targetAnnotation = AnnotationUtils.getAnnotation(ClassUtils.getUserClass(beanType), type);
origin: org.springframework/spring-beans

boolean checkMeta = true;
boolean fallbackToMeta = false;
if (isQualifier(type)) {
  if (!checkQualifier(bdHolder, annotation, typeConverter)) {
    fallbackToMeta = true;
  for (Annotation metaAnn : type.getAnnotations()) {
    Class<? extends Annotation> metaType = metaAnn.annotationType();
    if (isQualifier(metaType)) {
      foundMeta = true;
          !checkQualifier(bdHolder, metaAnn, typeConverter)) {
        return false;
origin: org.springframework/spring-beans

/**
 * Determine whether the provided bean definition is an autowire candidate.
 * <p>To be considered a candidate the bean's <em>autowire-candidate</em>
 * attribute must not have been set to 'false'. Also, if an annotation on
 * the field or parameter to be autowired is recognized by this bean factory
 * as a <em>qualifier</em>, the bean must 'match' against the annotation as
 * well as any attributes it may contain. The bean definition must contain
 * the same qualifier or match by meta attributes. A "value" attribute will
 * fallback to match against the bean name or an alias if a qualifier or
 * attribute does not match.
 * @see Qualifier
 */
@Override
public boolean isAutowireCandidate(BeanDefinitionHolder bdHolder, DependencyDescriptor descriptor) {
  boolean match = super.isAutowireCandidate(bdHolder, descriptor);
  if (match) {
    match = checkQualifiers(bdHolder, descriptor.getAnnotations());
    if (match) {
      MethodParameter methodParam = descriptor.getMethodParameter();
      if (methodParam != null) {
        Method method = methodParam.getMethod();
        if (method == null || void.class == method.getReturnType()) {
          match = checkQualifiers(bdHolder, methodParam.getMethodAnnotations());
        }
      }
    }
  }
  return match;
}
org.springframework.beans.factory.annotationQualifierAnnotationAutowireCandidateResolver

Javadoc

AutowireCandidateResolver implementation that matches bean definition qualifiers against Qualifier on the field or parameter to be autowired. Also supports suggested expression values through a Value annotation.

Also supports JSR-330's javax.inject.Qualifier annotation, if available.

Most used methods

  • <init>
    Create a new QualifierAnnotationAutowireCandidateResolver for the given qualifier annotation types.
  • addQualifierType
    Register the given type to be used as a qualifier when autowiring.This identifies qualifier annotati
  • checkQualifier
    Match the given qualifier annotation against the candidate bean definition.
  • checkQualifiers
    Match the given qualifier annotations against the candidate bean definition.
  • isQualifier
    Checks whether the given annotation type is a recognized qualifier type.
  • extractValue
    Extract the value attribute from the given annotation.
  • findValue
    Determine a suggested value from any of the given candidate annotations.
  • getBeanFactory
  • getFactoryMethodAnnotation
  • getQualifiedElementAnnotation
  • getResolvedDecoratedDefinition
  • getSuggestedValue
    Determine whether the given dependency declares a value annotation.
  • getResolvedDecoratedDefinition,
  • getSuggestedValue,
  • setBeanFactory

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getSystemService (Context)
  • onRequestPermissionsResult (Fragment)
  • getApplicationContext (Context)
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now