Search in sources :

Example 1 with BeanWiringInfo

use of org.springframework.beans.factory.wiring.BeanWiringInfo in project spring-framework by spring-projects.

the class AnnotationBeanWiringInfoResolverTests method testResolveWiringInfoWithAnInstanceOfANonAnnotatedClass.

@Test
public void testResolveWiringInfoWithAnInstanceOfANonAnnotatedClass() {
    AnnotationBeanWiringInfoResolver resolver = new AnnotationBeanWiringInfoResolver();
    BeanWiringInfo info = resolver.resolveWiringInfo("java.lang.String is not @Configurable");
    assertNull("Must be returning null for a non-@Configurable class instance", info);
}
Also used : BeanWiringInfo(org.springframework.beans.factory.wiring.BeanWiringInfo) Test(org.junit.Test)

Example 2 with BeanWiringInfo

use of org.springframework.beans.factory.wiring.BeanWiringInfo in project spring-framework by spring-projects.

the class AnnotationBeanWiringInfoResolverTests method testResolveWiringInfoWithAnInstanceOfAnAnnotatedClassWithAutowiringTurnedOffExplicitlyAndCustomBeanName.

@Test
public void testResolveWiringInfoWithAnInstanceOfAnAnnotatedClassWithAutowiringTurnedOffExplicitlyAndCustomBeanName() {
    AnnotationBeanWiringInfoResolver resolver = new AnnotationBeanWiringInfoResolver();
    BeanWiringInfo info = resolver.resolveWiringInfo(new NamedWirelessSoap());
    assertNotNull("Must *not* be returning null for an @Configurable class instance even when autowiring is NO", info);
    assertFalse(info.indicatesAutowiring());
    assertEquals("DerBigStick", info.getBeanName());
}
Also used : BeanWiringInfo(org.springframework.beans.factory.wiring.BeanWiringInfo) Test(org.junit.Test)

Example 3 with BeanWiringInfo

use of org.springframework.beans.factory.wiring.BeanWiringInfo in project cxf by apache.

the class ConfigurerImpl method configureBean.

public synchronized void configureBean(String bn, Object beanInstance, boolean checkWildcards) {
    if (null == appContexts) {
        return;
    }
    if (null == bn) {
        bn = getBeanName(beanInstance);
    }
    if (null == bn) {
        return;
    }
    if (checkWildcards) {
        configureWithWildCard(bn, beanInstance);
    }
    final String beanName = bn;
    setBeanWiringInfoResolver(new BeanWiringInfoResolver() {

        public BeanWiringInfo resolveWiringInfo(Object instance) {
            if (!"".equals(beanName)) {
                return new BeanWiringInfo(beanName);
            }
            return null;
        }
    });
    for (ApplicationContext appContext : appContexts) {
        if (appContext.containsBean(bn)) {
            this.setBeanFactory(appContext.getAutowireCapableBeanFactory());
        }
    }
    try {
        // this can leak memory
        if (beanFactory instanceof AbstractBeanFactory) {
            ((AbstractBeanFactory) beanFactory).getMergedBeanDefinition(bn);
        }
        super.configureBean(beanInstance);
        if (LOG.isLoggable(Level.FINE)) {
            LOG.fine("Successfully performed injection.");
        }
    } catch (NoSuchBeanDefinitionException ex) {
        // incorrect bean ids
        if (LOG.isLoggable(Level.FINE)) {
            LOG.log(Level.FINE, "NO_MATCHING_BEAN_MSG", beanName);
        }
    }
}
Also used : BeanWiringInfo(org.springframework.beans.factory.wiring.BeanWiringInfo) ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) AbstractBeanFactory(org.springframework.beans.factory.support.AbstractBeanFactory) BeanWiringInfoResolver(org.springframework.beans.factory.wiring.BeanWiringInfoResolver) NoSuchBeanDefinitionException(org.springframework.beans.factory.NoSuchBeanDefinitionException)

Example 4 with BeanWiringInfo

use of org.springframework.beans.factory.wiring.BeanWiringInfo in project spring-framework by spring-projects.

the class AnnotationBeanWiringInfoResolverTests method testResolveWiringInfoWithAnInstanceOfAnAnnotatedClassWithAutowiringTurnedOffExplicitly.

@Test
public void testResolveWiringInfoWithAnInstanceOfAnAnnotatedClassWithAutowiringTurnedOffExplicitly() {
    AnnotationBeanWiringInfoResolver resolver = new AnnotationBeanWiringInfoResolver();
    BeanWiringInfo info = resolver.resolveWiringInfo(new WirelessSoap());
    assertNotNull("Must *not* be returning null for an @Configurable class instance even when autowiring is NO", info);
    assertFalse(info.indicatesAutowiring());
    assertEquals(WirelessSoap.class.getName(), info.getBeanName());
}
Also used : BeanWiringInfo(org.springframework.beans.factory.wiring.BeanWiringInfo) Test(org.junit.Test)

Example 5 with BeanWiringInfo

use of org.springframework.beans.factory.wiring.BeanWiringInfo in project spring-framework by spring-projects.

the class AnnotationBeanWiringInfoResolverTests method testResolveWiringInfoWithAnInstanceOfAnAnnotatedClass.

@Test
public void testResolveWiringInfoWithAnInstanceOfAnAnnotatedClass() {
    AnnotationBeanWiringInfoResolver resolver = new AnnotationBeanWiringInfoResolver();
    BeanWiringInfo info = resolver.resolveWiringInfo(new Soap());
    assertNotNull("Must *not* be returning null for a non-@Configurable class instance", info);
}
Also used : BeanWiringInfo(org.springframework.beans.factory.wiring.BeanWiringInfo) Test(org.junit.Test)

Aggregations

BeanWiringInfo (org.springframework.beans.factory.wiring.BeanWiringInfo)5 Test (org.junit.Test)4 NoSuchBeanDefinitionException (org.springframework.beans.factory.NoSuchBeanDefinitionException)1 AbstractBeanFactory (org.springframework.beans.factory.support.AbstractBeanFactory)1 BeanWiringInfoResolver (org.springframework.beans.factory.wiring.BeanWiringInfoResolver)1 ApplicationContext (org.springframework.context.ApplicationContext)1 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)1