List of usage examples for org.springframework.context.annotation ScannedGenericBeanDefinition setAutowireMode
public void setAutowireMode(int autowireMode)
From source file:com.longio.spring.LioBootstrap.java
private void registerLioDefinition(ConfigurableListableBeanFactory beanFactory, BeanDefinition beanDefinition) { final String LioClassName = beanDefinition.getBeanClassName(); MutablePropertyValues propertyValues = beanDefinition.getPropertyValues(); /*/*from ww w. j a va 2 s .co m*/ * ?? MongoFactoryBean ?? */ propertyValues.addPropertyValue("objectType", LioClassName); ScannedGenericBeanDefinition scannedBeanDefinition = (ScannedGenericBeanDefinition) beanDefinition; scannedBeanDefinition.setPropertyValues(propertyValues); scannedBeanDefinition.setBeanClass(LioFactoryBean.class); scannedBeanDefinition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE); DefaultListableBeanFactory defaultBeanFactory = (DefaultListableBeanFactory) beanFactory; defaultBeanFactory.registerBeanDefinition(LioClassName, beanDefinition); }
From source file:org.devefx.httpmapper.spring.mapper.ClassPathMapperScanner.java
private void processBeanDefinitions(Set<BeanDefinitionHolder> beanDefinitions) { ScannedGenericBeanDefinition definition; for (BeanDefinitionHolder holder : beanDefinitions) { definition = (ScannedGenericBeanDefinition) holder.getBeanDefinition(); if (logger.isDebugEnabled()) { logger.debug("Creating MapperFactoryBean with name '" + holder.getBeanName() + "' and '" + definition.getBeanClassName() + "' mapperInterface"); }// w w w . java2 s . c o m // the mapper interface is the original class of the bean // but, the actual class of the bean is MapperFactoryBean definition.getConstructorArgumentValues().addGenericArgumentValue(definition.getBeanClassName()); definition.setBeanClass(this.factoryBeanClass); boolean explicitFactoryUsed = false; if (StringUtils.hasText(this.configBeanName)) { definition.getPropertyValues().add("config", new RuntimeBeanReference(this.configBeanName)); explicitFactoryUsed = true; } if (!explicitFactoryUsed) { if (logger.isDebugEnabled()) { logger.debug("Enabling autowire by type for MapperFactoryBean with name '" + holder.getBeanName() + "'."); } definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE); } } }