Java Code Examples for org.springframework.beans.factory.support.GenericBeanDefinition#getPropertyValues()
The following examples show how to use
org.springframework.beans.factory.support.GenericBeanDefinition#getPropertyValues() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DynamicDataSourceRegister.java From Aooms with Apache License 2.0 | 6 votes |
@Override public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanDefinitionRegistry beanDefinitionRegistry) { Map<Object, Object> targetDataSources = new HashMap<Object, Object>(); // 将主数据源添加到更多数据源中 targetDataSources.put(AoomsVar.DEFAULT_DATASOURCE, defaultDataSource); DynamicDataSourceHolder.dataSourceIds.add(AoomsVar.DEFAULT_DATASOURCE); // 添加更多数据源 targetDataSources.putAll(moreDataSources); for (String key : moreDataSources.keySet()) { DynamicDataSourceHolder.dataSourceIds.add(key); } // 创建DynamicDataSource GenericBeanDefinition beanDefinition = new GenericBeanDefinition(); beanDefinition.setBeanClass(DynamicDataSource.class); beanDefinition.setSynthetic(true); MutablePropertyValues mpv = beanDefinition.getPropertyValues(); // 添加属性:AbstractRoutingDataSource.defaultTargetDataSource mpv.addPropertyValue("defaultTargetDataSource", defaultDataSource); mpv.addPropertyValue("targetDataSources", targetDataSources); beanDefinitionRegistry.registerBeanDefinition(AoomsVar.DEFAULT_DATASOURCE, beanDefinition); }
Example 2
Source File: MangoDaoAutoCreator.java From mango-spring-boot-starter with Apache License 2.0 | 5 votes |
/** * 向spring中注入dao代理 * @param beanFactory */ private void registryMangoDao(DefaultListableBeanFactory beanFactory){ for (Class<?> daoClass : findMangoDaoClasses(config.getScanPackage())) { GenericBeanDefinition bf = new GenericBeanDefinition(); bf.setBeanClassName(daoClass.getName()); MutablePropertyValues pvs = bf.getPropertyValues(); pvs.addPropertyValue("daoClass", daoClass); bf.setBeanClass(factoryBeanClass); bf.setPropertyValues(pvs); bf.setLazyInit(false); beanFactory.registerBeanDefinition(daoClass.getName(), bf); } }
Example 3
Source File: MangoDaoScanner.java From mango with Apache License 2.0 | 5 votes |
@Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { DefaultListableBeanFactory dlbf = (DefaultListableBeanFactory) beanFactory; for (Class<?> daoClass : findMangoDaoClasses()) { GenericBeanDefinition bf = new GenericBeanDefinition(); bf.setBeanClassName(daoClass.getName()); MutablePropertyValues pvs = bf.getPropertyValues(); pvs.addPropertyValue("daoClass", daoClass); bf.setBeanClass(factoryBeanClass); bf.setPropertyValues(pvs); bf.setLazyInit(false); dlbf.registerBeanDefinition(daoClass.getName(), bf); } }