use of org.springframework.beans.factory.config.ConfigurableListableBeanFactory in project spring-boot by spring-projects.
the class SessionAutoConfigurationJdbcTests method sessionRepositoryBeansDependOnFlyway.
@Test
void sessionRepositoryBeansDependOnFlyway() {
this.contextRunner.withConfiguration(AutoConfigurations.of(FlywayAutoConfiguration.class)).withPropertyValues("spring.session.store-type=jdbc", "spring.session.jdbc.initialize-schema=never").run((context) -> {
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
String[] sessionRepositoryNames = beanFactory.getBeanNamesForType(JdbcIndexedSessionRepository.class);
assertThat(sessionRepositoryNames).isNotEmpty();
for (String sessionRepositoryName : sessionRepositoryNames) {
assertThat(beanFactory.getBeanDefinition(sessionRepositoryName).getDependsOn()).contains("flyway", "flywayInitializer");
}
});
}
use of org.springframework.beans.factory.config.ConfigurableListableBeanFactory in project spring-boot by spring-projects.
the class ShutdownEndpointAutoConfigurationTests method runShouldHaveEndpointBeanThatIsNotDisposable.
@Test
@SuppressWarnings("unchecked")
void runShouldHaveEndpointBeanThatIsNotDisposable() {
this.contextRunner.withPropertyValues("management.endpoint.shutdown.enabled:true").withPropertyValues("management.endpoints.web.exposure.include=shutdown").run((context) -> {
assertThat(context).hasSingleBean(ShutdownEndpoint.class);
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
Map<String, Object> disposableBeans = (Map<String, Object>) ReflectionTestUtils.getField(beanFactory, "disposableBeans");
assertThat(disposableBeans).isEmpty();
});
}
use of org.springframework.beans.factory.config.ConfigurableListableBeanFactory 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.config.ConfigurableListableBeanFactory 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
}
}
use of org.springframework.beans.factory.config.ConfigurableListableBeanFactory in project dubbo by alibaba.
the class ReferenceAnnotationBeanPostProcessor method registerReferenceBean.
/**
* Register an instance of {@link ReferenceBean} as a Spring Bean
*
* @param referencedBeanName The name of bean that annotated Dubbo's {@link Service @Service} in the Spring {@link ApplicationContext}
* @param referenceBean the instance of {@link ReferenceBean} is about to register into the Spring {@link ApplicationContext}
* @param attributes the {@link AnnotationAttributes attributes} of {@link Reference @Reference}
* @param localServiceBean Is Local Service bean or not
* @param interfaceClass the {@link Class class} of Service interface
* @since 2.7.3
*/
private void registerReferenceBean(String referencedBeanName, ReferenceBean referenceBean, boolean localServiceBean, String beanName) {
ConfigurableListableBeanFactory beanFactory = getBeanFactory();
if (localServiceBean) {
// If @Service bean is local one
/**
* Get the @Service's BeanDefinition from {@link BeanFactory}
* Refer to {@link ServiceClassPostProcessor#buildServiceBeanDefinition}
*/
AbstractBeanDefinition beanDefinition = (AbstractBeanDefinition) beanFactory.getBeanDefinition(referencedBeanName);
RuntimeBeanReference runtimeBeanReference = (RuntimeBeanReference) beanDefinition.getPropertyValues().get("ref");
// The name of bean annotated @Service
String serviceBeanName = runtimeBeanReference.getBeanName();
// register Alias rather than a new bean name, in order to reduce duplicated beans
beanFactory.registerAlias(serviceBeanName, beanName);
} else {
// Remote @Service Bean
if (!beanFactory.containsBean(beanName)) {
beanFactory.registerSingleton(beanName, referenceBean);
}
}
}
Aggregations