Package org.springframework.boot
Interface ApplicationContextFactory
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Strategy interface for creating the 
ConfigurableApplicationContext used by a
 SpringApplication. Created contexts should be returned in their default form,
 with the SpringApplication responsible for configuring and refreshing the
 context.- Since:
- 2.4.0
- Author:
- Andy Wilkinson, Phillip Webb
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final ApplicationContextFactoryA defaultApplicationContextFactoryimplementation that will create an appropriate context for theWebApplicationType.
- 
Method SummaryModifier and TypeMethodDescriptioncreate(WebApplicationType webApplicationType) default ConfigurableEnvironmentcreateEnvironment(WebApplicationType webApplicationType) Create a newEnvironmentto be set on thecreatedapplication context.default Class<? extends ConfigurableEnvironment>getEnvironmentType(WebApplicationType webApplicationType) Return theEnvironmenttype expected to be set on thecreatedapplication context.static ApplicationContextFactoryof(Supplier<ConfigurableApplicationContext> supplier) Creates anApplicationContextFactorythat will create contexts by calling the givenSupplier.static ApplicationContextFactoryofContextClass(Class<? extends ConfigurableApplicationContext> contextClass) Creates anApplicationContextFactorythat will create contexts by instantiating the givencontextClassthrough its primary constructor.
- 
Field Details- 
DEFAULTA defaultApplicationContextFactoryimplementation that will create an appropriate context for theWebApplicationType.
 
- 
- 
Method Details- 
getEnvironmentTypedefault Class<? extends ConfigurableEnvironment> getEnvironmentType(WebApplicationType webApplicationType) Return theEnvironmenttype expected to be set on thecreatedapplication context. The result of this method can be used to convert an existing environment instance to the correct type.- Parameters:
- webApplicationType- the web application type
- Returns:
- the expected application context type or nullto use the default
- Since:
- 2.6.14
 
- 
createEnvironmentCreate a newEnvironmentto be set on thecreatedapplication context. The result of this method must match the type returned bygetEnvironmentType(WebApplicationType).- Parameters:
- webApplicationType- the web application type
- Returns:
- an environment instance or nullto use the default
- Since:
- 2.6.14
 
- 
create- Parameters:
- webApplicationType- the web application type
- Returns:
- the newly created application context
 
- 
ofContextClassstatic ApplicationContextFactory ofContextClass(Class<? extends ConfigurableApplicationContext> contextClass) Creates anApplicationContextFactorythat will create contexts by instantiating the givencontextClassthrough its primary constructor.- Parameters:
- contextClass- the context class
- Returns:
- the factory that will instantiate the context class
- See Also:
 
- 
ofCreates anApplicationContextFactorythat will create contexts by calling the givenSupplier.- Parameters:
- supplier- the context supplier, for example- AnnotationConfigApplicationContext::new
- Returns:
- the factory that will instantiate the context class
 
 
-