Example usage for org.springframework.beans.factory.wiring BeanWiringInfo BeanWiringInfo

List of usage examples for org.springframework.beans.factory.wiring BeanWiringInfo BeanWiringInfo

Introduction

In this page you can find the example usage for org.springframework.beans.factory.wiring BeanWiringInfo BeanWiringInfo.

Prototype

public BeanWiringInfo(String beanName) 

Source Link

Document

Create a new BeanWiringInfo that points to the given bean name.

Usage

From source file:org.solmix.runtime.support.spring.SpringConfigurer.java

public synchronized void configureBean(String bn, Object beanInstance, boolean checkWildcards) {

    if (null == appContexts) {
        return;// w  ww .  ja  va 2s  .c o  m
    }

    if (null == bn) {
        bn = getBeanName(beanInstance);
    }

    if (null == bn) {
        return;
    }
    //configure bean with * pattern style.
    if (checkWildcards) {
        configureWithWildCard(bn, beanInstance);
    }

    final String beanName = bn;
    setBeanWiringInfoResolver(new BeanWiringInfoResolver() {
        @Override
        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 will prevent a call into the AbstractBeanFactory.markBeanAsCreated(...)
        //which saves ALL the names into a HashSet.  For URL based configuration,
        //this can leak memory
        if (beanFactory instanceof AbstractBeanFactory) {
            ((AbstractBeanFactory) beanFactory).getMergedBeanDefinition(bn);
        }
        super.configureBean(beanInstance);
        if (LOG.isTraceEnabled()) {
            LOG.trace("Successfully performed injection,used beanName:{}", beanName);
        }
    } catch (NoSuchBeanDefinitionException ex) {
        // users often wonder why the settings in their configuration files seem
        // to have no effect - the most common cause is that they have been using
        // incorrect bean ids
        if (LOG.isDebugEnabled()) {
            LOG.debug("No matching bean {}", beanName);
        }
    }
}