本文整理汇总了Java中org.springframework.beans.factory.support.GenericBeanDefinition.setSynthetic方法的典型用法代码示例。如果您正苦于以下问题:Java GenericBeanDefinition.setSynthetic方法的具体用法?Java GenericBeanDefinition.setSynthetic怎么用?Java GenericBeanDefinition.setSynthetic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.beans.factory.support.GenericBeanDefinition
的用法示例。
在下文中一共展示了GenericBeanDefinition.setSynthetic方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerBeanDefinitions
import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
Map<Object, Object> targetDataSources = new HashMap<Object, Object>();
// 将主数据源添加到更多数据源中
targetDataSources.put("dataSource", defaultDataSource);
DynamicDataSourceContextHolder.dataSourceIds.add("dataSource");
// 添加更多数据源
targetDataSources.putAll(customDataSources);
for (String key : customDataSources.keySet()) {
DynamicDataSourceContextHolder.dataSourceIds.add(key);
}
// 创建DynamicDataSource
GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
beanDefinition.setBeanClass(DynamicDataSource.class);
beanDefinition.setSynthetic(true);
MutablePropertyValues mpv = beanDefinition.getPropertyValues();
mpv.addPropertyValue("defaultTargetDataSource", defaultDataSource);
mpv.addPropertyValue("targetDataSources", targetDataSources);
registry.registerBeanDefinition("dataSource", beanDefinition);
logger.info("Dynamic DataSource Registry");
}
示例2: createBeanReferenceDefinition
import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
private AbstractBeanDefinition createBeanReferenceDefinition(String beanName, BeanDefinition actualDef) {
GenericBeanDefinition def = new GenericBeanDefinition();
def.setBeanClass(BeanReferenceFactoryBean.class);
def.setAttribute(GENERATED_REF, Boolean.TRUE);
def.setOriginatingBeanDefinition(actualDef);
def.setDependsOn(new String[] { beanName });
def.setSynthetic(true);
MutablePropertyValues mpv = new MutablePropertyValues();
mpv.addPropertyValue(TARGET_BEAN_NAME_PROP, beanName);
def.setPropertyValues(mpv);
return def;
}
示例3: registerBeanDefinitions
import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("动态数据源注册开始>>>");
}
// 添加主数据源
targetDataSources.put("master", DynamicDataSourceHolder.getMasterDS());
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("提供可选取Master数据源:{}", "master");
}
// 添加从数据源
targetDataSources.putAll(DynamicDataSourceHolder.getSlaveDSMap());
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("提供可选取Slave数据源:{}", DynamicDataSourceHolder.getSlaveDSMap().keySet());
}
for (String key : DynamicDataSourceHolder.getSlaveDSMap().keySet()) {
DynamicDataSourceHolder.getSlaveDSKeys().add(key);
}
// 创建DynamicDataSource
GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
beanDefinition.setBeanClass(DynamicDataSource.class);
beanDefinition.setSynthetic(true);
MutablePropertyValues mpv = beanDefinition.getPropertyValues();
mpv.addPropertyValue("defaultTargetDataSource", DynamicDataSourceHolder.getMasterDS());
mpv.addPropertyValue("targetDataSources", targetDataSources);
registry.registerBeanDefinition("dataSource", beanDefinition);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("<<<动态数据源注册结束");
}
}
示例4: registerDynamicDataSourceBeanDefinition
import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
/**
* @Title: registerDynamicDataSourceBeanDefinition
* @Description: 注册动态数据源
* @author Kola 6089555
* @date 2017年4月26日 下午1:26:55
* @param registry
*/
private void registerDynamicDataSourceBeanDefinition(BeanDefinitionRegistry registry) {
GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
beanDefinition.setBeanClass(DynamicDataSource.class);
beanDefinition.setSynthetic(true);
beanDefinition.setPrimary(true);
MutablePropertyValues mpv = beanDefinition.getPropertyValues();
mpv.addPropertyValue("defaultTargetDataSource", defaultDataSource);
mpv.addPropertyValue("targetDataSources", targetDataSources);
registry.registerBeanDefinition("dataSource", beanDefinition);
LOGGER.info("Dynamic DataSource Registry");
}
开发者ID:6089555,项目名称:spring-boot-starter-dynamic-datasource,代码行数:19,代码来源:DynamicDataSourceRegister.java
示例5: addEntityScanBeanPostProcessor
import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
private void addEntityScanBeanPostProcessor(BeanDefinitionRegistry registry,
Set<String> packagesToScan) {
GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
beanDefinition.setBeanClass(EntityScanBeanPostProcessor.class);
beanDefinition.getConstructorArgumentValues()
.addGenericArgumentValue(toArray(packagesToScan));
beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
// We don't need this one to be post processed otherwise it can cause a
// cascade of bean instantiation that we would rather avoid.
beanDefinition.setSynthetic(true);
registry.registerBeanDefinition(BEAN_NAME, beanDefinition);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:13,代码来源:EntityScanRegistrar.java
示例6: registerBeanDefinitions
import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata,
BeanDefinitionRegistry registry) {
if (!registry.containsBeanDefinition(BEAN_NAME)) {
GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
beanDefinition.setBeanClass(DataSourceInitializerPostProcessor.class);
beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
// We don't need this one to be post processed otherwise it can cause a
// cascade of bean instantiation that we would rather avoid.
beanDefinition.setSynthetic(true);
registry.registerBeanDefinition(BEAN_NAME, beanDefinition);
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:DataSourceInitializerPostProcessor.java
示例7: registerBeanDefinitions
import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata,
BeanDefinitionRegistry registry) {
if (!registry.containsBeanDefinition(BEAN_NAME)) {
GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
beanDefinition.setBeanClass(DataSourceInitializedPublisher.class);
beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
// We don't need this one to be post processed otherwise it can cause a
// cascade of bean instantiation that we would rather avoid.
beanDefinition.setSynthetic(true);
registry.registerBeanDefinition(BEAN_NAME, beanDefinition);
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:DataSourceInitializedPublisher.java
示例8: addEntityScanBeanPostProcessor
import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
private void addEntityScanBeanPostProcessor(BeanDefinitionRegistry registry,
Set<String> packagesToScan) {
GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
beanDefinition.setBeanClass(this.beanPostProcessorType);
beanDefinition.getConstructorArgumentValues()
.addGenericArgumentValue(toArray(packagesToScan));
beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
// We don't need this one to be post processed otherwise it can cause a
// cascade of bean instantiation that we would rather avoid.
beanDefinition.setSynthetic(true);
registry.registerBeanDefinition(this.beanPostProcessorName, beanDefinition);
}