List of usage examples for org.springframework.beans.factory.wiring BeanWiringInfoResolver resolveWiringInfo
@Nullable BeanWiringInfo resolveWiringInfo(Object beanInstance);
From source file:org.springframework.beans.factory.wiring.BeanConfigurerSupport.java
/** * Configure the bean instance.//from w w w. j a v a2 s. c om * <p>Subclasses can override this to provide custom configuration logic. * Typically called by an aspect, for all bean instances matched by a pointcut. * @param beanInstance the bean instance to configure (must <b>not</b> be {@code null}) */ public void configureBean(Object beanInstance) { if (this.beanFactory == null) { if (logger.isDebugEnabled()) { logger.debug("BeanFactory has not been set on " + ClassUtils.getShortName(getClass()) + ": " + "Make sure this configurer runs in a Spring container. Unable to configure bean of type [" + ClassUtils.getDescriptiveType(beanInstance) + "]. Proceeding without injection."); } return; } BeanWiringInfoResolver bwiResolver = this.beanWiringInfoResolver; Assert.state(bwiResolver != null, "No BeanWiringInfoResolver available"); BeanWiringInfo bwi = bwiResolver.resolveWiringInfo(beanInstance); if (bwi == null) { // Skip the bean if no wiring info given. return; } ConfigurableListableBeanFactory beanFactory = this.beanFactory; Assert.state(beanFactory != null, "No BeanFactory available"); try { if (bwi.indicatesAutowiring() || (bwi.isDefaultBeanName() && bwi.getBeanName() != null && !beanFactory.containsBean(bwi.getBeanName()))) { // Perform autowiring (also applying standard factory / post-processor callbacks). beanFactory.autowireBeanProperties(beanInstance, bwi.getAutowireMode(), bwi.getDependencyCheck()); beanFactory.initializeBean(beanInstance, bwi.getBeanName()); } else { // Perform explicit wiring based on the specified bean definition. beanFactory.configureBean(beanInstance, bwi.getBeanName()); } } catch (BeanCreationException ex) { Throwable rootCause = ex.getMostSpecificCause(); if (rootCause instanceof BeanCurrentlyInCreationException) { BeanCreationException bce = (BeanCreationException) rootCause; String bceBeanName = bce.getBeanName(); if (bceBeanName != null && beanFactory.isCurrentlyInCreation(bceBeanName)) { if (logger.isDebugEnabled()) { logger.debug("Failed to create target bean '" + bce.getBeanName() + "' while configuring object of type [" + beanInstance.getClass().getName() + "] - probably due to a circular reference. This is a common startup situation " + "and usually not fatal. Proceeding without injection. Original exception: " + ex); } return; } } throw ex; } }