use of org.springframework.beans.factory.support.BeanDefinitionRegistry in project dubbo by alibaba.
the class DubboConfigBeanDefinitionConflictApplicationListener method onApplicationEvent.
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
ApplicationContext applicationContext = event.getApplicationContext();
BeanDefinitionRegistry registry = getBeanDefinitionRegistry(applicationContext);
resolveUniqueApplicationConfigBean(registry, applicationContext);
}
use of org.springframework.beans.factory.support.BeanDefinitionRegistry in project spring-boot by spring-projects.
the class ConfigurationPropertiesTests method loadWhenBeanFactoryContainsSingletonForConstructorBindingTypeShouldNotFail.
// gh-18652
@Test
void loadWhenBeanFactoryContainsSingletonForConstructorBindingTypeShouldNotFail() {
ConfigurableListableBeanFactory beanFactory = this.context.getBeanFactory();
((BeanDefinitionRegistry) beanFactory).registerBeanDefinition("test", new RootBeanDefinition(ConstructorParameterProperties.class));
beanFactory.registerSingleton("test", new ConstructorParameterProperties("bar", 5));
load(TestConfiguration.class);
}
use of org.springframework.beans.factory.support.BeanDefinitionRegistry in project spring-boot by spring-projects.
the class SharedMetadataReaderFactoryContextInitializerTests method initializeWhenUsingSupplierDecorates.
@Test
void initializeWhenUsingSupplierDecorates() {
GenericApplicationContext context = new GenericApplicationContext();
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) context.getBeanFactory();
ConfigurationClassPostProcessor configurationAnnotationPostProcessor = mock(ConfigurationClassPostProcessor.class);
BeanDefinition beanDefinition = BeanDefinitionBuilder.genericBeanDefinition(ConfigurationClassPostProcessor.class).getBeanDefinition();
((AbstractBeanDefinition) beanDefinition).setInstanceSupplier(() -> configurationAnnotationPostProcessor);
registry.registerBeanDefinition(AnnotationConfigUtils.CONFIGURATION_ANNOTATION_PROCESSOR_BEAN_NAME, beanDefinition);
CachingMetadataReaderFactoryPostProcessor postProcessor = new CachingMetadataReaderFactoryPostProcessor(context);
postProcessor.postProcessBeanDefinitionRegistry(registry);
context.refresh();
ConfigurationClassPostProcessor bean = context.getBean(ConfigurationClassPostProcessor.class);
assertThat(bean).isSameAs(configurationAnnotationPostProcessor);
ArgumentCaptor<MetadataReaderFactory> metadataReaderFactory = ArgumentCaptor.forClass(MetadataReaderFactory.class);
then(configurationAnnotationPostProcessor).should().setMetadataReaderFactory(metadataReaderFactory.capture());
assertThat(metadataReaderFactory.getValue()).isInstanceOf(ConcurrentReferenceCachingMetadataReaderFactory.class);
}
use of org.springframework.beans.factory.support.BeanDefinitionRegistry in project spring-boot by spring-projects.
the class ServletManagementContextFactory method registerServletWebServerFactory.
private void registerServletWebServerFactory(ApplicationContext parent, AnnotationConfigServletWebServerApplicationContext childContext) {
try {
ConfigurableListableBeanFactory beanFactory = childContext.getBeanFactory();
if (beanFactory instanceof BeanDefinitionRegistry) {
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
registry.registerBeanDefinition("ServletWebServerFactory", new RootBeanDefinition(determineServletWebServerFactoryClass(parent)));
}
} catch (NoSuchBeanDefinitionException ex) {
// Ignore and assume auto-configuration
}
}
use of org.springframework.beans.factory.support.BeanDefinitionRegistry in project spring-boot by spring-projects.
the class ReactiveManagementContextFactory method registerReactiveWebServerFactory.
private void registerReactiveWebServerFactory(ApplicationContext parent, AnnotationConfigReactiveWebServerApplicationContext childContext) {
try {
ConfigurableListableBeanFactory beanFactory = childContext.getBeanFactory();
if (beanFactory instanceof BeanDefinitionRegistry) {
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
registry.registerBeanDefinition("ReactiveWebServerFactory", new RootBeanDefinition(determineReactiveWebServerFactoryClass(parent)));
}
} catch (NoSuchBeanDefinitionException ex) {
// Ignore and assume auto-configuration
}
}
Aggregations