use of org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory in project spring-boot by spring-projects.
the class AbstractApplicationContextRunner method createAndLoadContext.
private C createAndLoadContext() {
C context = this.runnerConfiguration.contextFactory.get();
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
if (beanFactory instanceof AbstractAutowireCapableBeanFactory) {
((AbstractAutowireCapableBeanFactory) beanFactory).setAllowCircularReferences(this.runnerConfiguration.allowCircularReferences);
if (beanFactory instanceof DefaultListableBeanFactory) {
((DefaultListableBeanFactory) beanFactory).setAllowBeanDefinitionOverriding(this.runnerConfiguration.allowBeanDefinitionOverriding);
}
}
try {
configureContext(context);
return context;
} catch (RuntimeException ex) {
context.close();
throw ex;
}
}
use of org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory in project spring-boot by spring-projects.
the class SpringApplication method prepareContext.
private void prepareContext(DefaultBootstrapContext bootstrapContext, ConfigurableApplicationContext context, ConfigurableEnvironment environment, SpringApplicationRunListeners listeners, ApplicationArguments applicationArguments, Banner printedBanner) {
context.setEnvironment(environment);
postProcessApplicationContext(context);
applyInitializers(context);
listeners.contextPrepared(context);
bootstrapContext.close(context);
if (this.logStartupInfo) {
logStartupInfo(context.getParent() == null);
logStartupProfileInfo(context);
}
// Add boot specific singleton beans
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
beanFactory.registerSingleton("springApplicationArguments", applicationArguments);
if (printedBanner != null) {
beanFactory.registerSingleton("springBootBanner", printedBanner);
}
if (beanFactory instanceof AbstractAutowireCapableBeanFactory) {
((AbstractAutowireCapableBeanFactory) beanFactory).setAllowCircularReferences(this.allowCircularReferences);
if (beanFactory instanceof DefaultListableBeanFactory) {
((DefaultListableBeanFactory) beanFactory).setAllowBeanDefinitionOverriding(this.allowBeanDefinitionOverriding);
}
}
if (this.lazyInitialization) {
context.addBeanFactoryPostProcessor(new LazyInitializationBeanFactoryPostProcessor());
}
// Load the sources
Set<Object> sources = getAllSources();
Assert.notEmpty(sources, "Sources must not be empty");
load(context, sources.toArray(new Object[0]));
listeners.contextLoaded(context);
}
use of org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory in project pf4j-spring by pf4j.
the class SpringPluginManager method init.
/**
* This method load, start plugins and inject extensions in Spring
*/
@PostConstruct
public void init() {
loadPlugins();
startPlugins();
AbstractAutowireCapableBeanFactory beanFactory = (AbstractAutowireCapableBeanFactory) applicationContext.getAutowireCapableBeanFactory();
ExtensionsInjector extensionsInjector = new ExtensionsInjector(this, beanFactory);
extensionsInjector.injectExtensions();
}
use of org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory in project spring-boot by spring-projects.
the class BeanCurrentlyInCreationFailureAnalyzerTests method createFailure.
private Exception createFailure(Class<?> configuration, boolean allowCircularReferences) {
try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) {
context.register(configuration);
AbstractAutowireCapableBeanFactory beanFactory = (AbstractAutowireCapableBeanFactory) context.getBeanFactory();
this.analyzer.setBeanFactory(beanFactory);
beanFactory.setAllowCircularReferences(allowCircularReferences);
context.refresh();
fail("Expected failure did not occur");
return null;
} catch (Exception ex) {
return ex;
}
}
Aggregations