Home / Function/ prepareContext() — spring-boot Function Reference

prepareContext() — spring-boot Function Reference

Architecture documentation for the prepareContext() function in SpringApplication.java from the spring-boot codebase.

Function java GradlePlugin DslExtensions calls 14 called by 1

Entity Profile

Dependency Diagram

graph TD
  6effd0c4_0207_6697_e91b_d163c77a8757["prepareContext()"]
  89cfa04a_3922_680e_945d_5b4338252cc7["run()"]
  89cfa04a_3922_680e_945d_5b4338252cc7 -->|calls| 6effd0c4_0207_6697_e91b_d163c77a8757
  bcb16b39_1cc9_8ad7_8ae2_fb817a35bf45["setEnvironment()"]
  6effd0c4_0207_6697_e91b_d163c77a8757 -->|calls| bcb16b39_1cc9_8ad7_8ae2_fb817a35bf45
  9dacb577_985f_f330_5af8_e845e130acd7["postProcessApplicationContext()"]
  6effd0c4_0207_6697_e91b_d163c77a8757 -->|calls| 9dacb577_985f_f330_5af8_e845e130acd7
  0119a9ba_0727_f255_b897_e77e52781c8e["addAotGeneratedInitializerIfNecessary()"]
  6effd0c4_0207_6697_e91b_d163c77a8757 -->|calls| 0119a9ba_0727_f255_b897_e77e52781c8e
  15f2f7d2_4f32_9146_6bfd_cbed7455fdf9["applyInitializers()"]
  6effd0c4_0207_6697_e91b_d163c77a8757 -->|calls| 15f2f7d2_4f32_9146_6bfd_cbed7455fdf9
  7dbdd22f_6929_2540_3475_c564a673879d["close()"]
  6effd0c4_0207_6697_e91b_d163c77a8757 -->|calls| 7dbdd22f_6929_2540_3475_c564a673879d
  e36af094_8d62_8a4e_3e55_1218615a7f8d["logStartupInfo()"]
  6effd0c4_0207_6697_e91b_d163c77a8757 -->|calls| e36af094_8d62_8a4e_3e55_1218615a7f8d
  fb48c3c9_a652_dd4c_a390_f9134a1b070d["logStartupProfileInfo()"]
  6effd0c4_0207_6697_e91b_d163c77a8757 -->|calls| fb48c3c9_a652_dd4c_a390_f9134a1b070d
  b7ba86d8_207e_2391_c657_08ced75cc7f3["setAllowCircularReferences()"]
  6effd0c4_0207_6697_e91b_d163c77a8757 -->|calls| b7ba86d8_207e_2391_c657_08ced75cc7f3
  773cd752_8508_b95c_fa23_cf09f5053bc8["setAllowBeanDefinitionOverriding()"]
  6effd0c4_0207_6697_e91b_d163c77a8757 -->|calls| 773cd752_8508_b95c_fa23_cf09f5053bc8
  0f3f9b82_7cba_db87_4a3e_608ae26b1c80["isKeepAlive()"]
  6effd0c4_0207_6697_e91b_d163c77a8757 -->|calls| 0f3f9b82_7cba_db87_4a3e_608ae26b1c80
  e7f2110e_00c8_ad92_8d05_da498f52d60b["PropertySourceOrderingBeanFactoryPostProcessor()"]
  6effd0c4_0207_6697_e91b_d163c77a8757 -->|calls| e7f2110e_00c8_ad92_8d05_da498f52d60b
  054bafb8_44ed_70f9_eaad_e693eb9d86e1["getAllSources()"]
  6effd0c4_0207_6697_e91b_d163c77a8757 -->|calls| 054bafb8_44ed_70f9_eaad_e693eb9d86e1
  5b8de0b8_93f1_dc4d_bc8b_9b614dc4c8e9["load()"]
  6effd0c4_0207_6697_e91b_d163c77a8757 -->|calls| 5b8de0b8_93f1_dc4d_bc8b_9b614dc4c8e9
  style 6effd0c4_0207_6697_e91b_d163c77a8757 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

core/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java lines 380–419

	private void prepareContext(DefaultBootstrapContext bootstrapContext, ConfigurableApplicationContext context,
			ConfigurableEnvironment environment, SpringApplicationRunListeners listeners,
			ApplicationArguments applicationArguments, @Nullable Banner printedBanner) {
		context.setEnvironment(environment);
		postProcessApplicationContext(context);
		addAotGeneratedInitializerIfNecessary(this.initializers);
		applyInitializers(context);
		listeners.contextPrepared(context);
		bootstrapContext.close(context);
		if (this.properties.isLogStartupInfo()) {
			logStartupInfo(context);
			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 autowireCapableBeanFactory) {
			autowireCapableBeanFactory.setAllowCircularReferences(this.properties.isAllowCircularReferences());
			if (beanFactory instanceof DefaultListableBeanFactory listableBeanFactory) {
				listableBeanFactory.setAllowBeanDefinitionOverriding(this.properties.isAllowBeanDefinitionOverriding());
			}
		}
		if (this.properties.isLazyInitialization()) {
			context.addBeanFactoryPostProcessor(new LazyInitializationBeanFactoryPostProcessor());
		}
		if (this.properties.isKeepAlive()) {
			context.addApplicationListener(new KeepAlive());
		}
		context.addBeanFactoryPostProcessor(new PropertySourceOrderingBeanFactoryPostProcessor(context));
		if (!AotDetector.useGeneratedArtifacts()) {
			// Load the sources
			Set<Object> sources = getAllSources();
			Assert.state(!ObjectUtils.isEmpty(sources), "No sources defined");
			load(context, sources.toArray(new Object[0]));
		}
		listeners.contextLoaded(context);
	}

Domain

Subdomains

Calls

Called By

Frequently Asked Questions

What does prepareContext() do?
prepareContext() is a function in the spring-boot codebase.
What does prepareContext() call?
prepareContext() calls 14 function(s): PropertySourceOrderingBeanFactoryPostProcessor, addAotGeneratedInitializerIfNecessary, applyInitializers, close, contextLoaded, getAllSources, isKeepAlive, load, and 6 more.
What calls prepareContext()?
prepareContext() is called by 1 function(s): run.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free