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 Summary
Modifier and TypeFieldDescriptionstatic final ApplicationContextFactory
A defaultApplicationContextFactory
implementation that will create an appropriate context for theWebApplicationType
. -
Method Summary
Modifier and TypeMethodDescriptioncreate
(WebApplicationType webApplicationType) static ApplicationContextFactory
of
(Supplier<ConfigurableApplicationContext> supplier) Creates anApplicationContextFactory
that will create contexts by calling the givenSupplier
.static ApplicationContextFactory
ofContextClass
(Class<? extends ConfigurableApplicationContext> contextClass) Creates anApplicationContextFactory
that will create contexts by instantiating the givencontextClass
via its primary constructor.
-
Field Details
-
DEFAULT
A defaultApplicationContextFactory
implementation that will create an appropriate context for theWebApplicationType
.
-
-
Method Details
-
create
- Parameters:
webApplicationType
- the web application type- Returns:
- the newly created application context
-
ofContextClass
static ApplicationContextFactory ofContextClass(Class<? extends ConfigurableApplicationContext> contextClass) Creates anApplicationContextFactory
that will create contexts by instantiating the givencontextClass
via its primary constructor.- Parameters:
contextClass
- the context class- Returns:
- the factory that will instantiate the context class
- See Also:
-
of
Creates anApplicationContextFactory
that will create contexts by calling the givenSupplier
.- Parameters:
supplier
- the context supplier, for exampleAnnotationConfigApplicationContext::new
- Returns:
- the factory that will instantiate the context class
-