Search in sources :

Example 1 with QualifierAnnotationAutowireCandidateResolver

use of org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver in project spring-framework by spring-projects.

the class QualifierAnnotationTests method testQualifiedByAttributesWithCustomQualifierRegistered.

@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);
}
Also used : BeanDefinitionReader(org.springframework.beans.factory.support.BeanDefinitionReader) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) QualifierAnnotationAutowireCandidateResolver(org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver) Test(org.junit.Test)

Example 2 with QualifierAnnotationAutowireCandidateResolver

use of org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver in project spring-framework by spring-projects.

the class ConfigurationClassPostProcessorTests method setup.

@Before
public void setup() {
    QualifierAnnotationAutowireCandidateResolver acr = new QualifierAnnotationAutowireCandidateResolver();
    acr.setBeanFactory(this.beanFactory);
    this.beanFactory.setAutowireCandidateResolver(acr);
}
Also used : QualifierAnnotationAutowireCandidateResolver(org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver) Before(org.junit.Before)

Aggregations

QualifierAnnotationAutowireCandidateResolver (org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver)2 Before (org.junit.Before)1 Test (org.junit.Test)1 BeanDefinitionReader (org.springframework.beans.factory.support.BeanDefinitionReader)1 StaticApplicationContext (org.springframework.context.support.StaticApplicationContext)1