Java Code Examples for org.springframework.beans.factory.support.GenericBeanDefinition#setSynthetic()

The following examples show how to use org.springframework.beans.factory.support.GenericBeanDefinition#setSynthetic() . 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 vote down vote up
@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: BeanPostProcessorRegister.java    From brpc-java with Apache License 2.0 5 votes vote down vote up
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata,
                                    BeanDefinitionRegistry registry) {
    GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
    beanDefinition.setBeanClass(CommonAnnotationBeanPostProcessor.class);
    beanDefinition.setSynthetic(true);
    MutablePropertyValues values = new MutablePropertyValues();
    values.addPropertyValue("callback", new SpringBootAnnotationResolver());
    beanDefinition.setPropertyValues(values);
    registry.registerBeanDefinition("commonAnnotationBeanPostProcessor", beanDefinition);
}
 
Example 3
Source File: TeiidPostProcessor.java    From teiid-spring-boot with Apache License 2.0 5 votes vote down vote up
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata,
        BeanDefinitionRegistry registry) {
    if (!registry.containsBeanDefinition(BEAN_NAME)) {
        GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
        beanDefinition.setBeanClass(TeiidPostProcessor.class);
        beanDefinition.setRole(BeanDefinition.ROLE_APPLICATION);
        // 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);
    }
}
 
Example 4
Source File: CustomizeImportBeanDefinitionRegistrar.java    From blog_demos with Apache License 2.0 5 votes vote down vote up
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
    if (!registry.containsBeanDefinition(BEAN_NAME)) {
        Utils.printTrack("start registerBeanDefinitions");
        GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
        beanDefinition.setBeanClass(CustomizeServiceImpl4.class);
        beanDefinition.setSynthetic(true);
        registry.registerBeanDefinition(BEAN_NAME, beanDefinition);
    }
}
 
Example 5
Source File: WebAdminComponentScanRegistrar.java    From wallride with Apache License 2.0 5 votes vote down vote up
private void addWebAdminComponentScanBeanPostProcessor(BeanDefinitionRegistry registry, Set<String> packagesToScan) {
	GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
	beanDefinition.setBeanClass(WebAdminComponentScanBeanPostProcessor.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);
}
 
Example 6
Source File: WebGuestComponentScanRegistrar.java    From wallride with Apache License 2.0 5 votes vote down vote up
private void addWebGuestComponentScanBeanPostProcessor(BeanDefinitionRegistry registry, Set<String> packagesToScan) {
	GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
	beanDefinition.setBeanClass(WebGuestComponentScanBeanPostProcessor.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);
}