@FunctionalInterface
public interface ApplicationContextFactory
ConfigurableApplicationContext
used by a
SpringApplication
. Created contexts should be returned in their default form,
with the SpringApplication
responsible for configuring and refreshing the
context.Modifier and Type | Field and Description |
---|---|
static ApplicationContextFactory |
DEFAULT
A default
ApplicationContextFactory implementation that will create an
appropriate context for the WebApplicationType . |
Modifier and Type | Method and Description |
---|---|
org.springframework.context.ConfigurableApplicationContext |
create(WebApplicationType webApplicationType)
|
default org.springframework.core.env.ConfigurableEnvironment |
createEnvironment(WebApplicationType webApplicationType)
Create a new
Environment to be set on the
created application context. |
default java.lang.Class<? extends org.springframework.core.env.ConfigurableEnvironment> |
getEnvironmentType(WebApplicationType webApplicationType)
Return the
Environment type expected to be set on the
created application context. |
static ApplicationContextFactory |
of(java.util.function.Supplier<org.springframework.context.ConfigurableApplicationContext> supplier)
Creates an
ApplicationContextFactory that will create contexts by calling
the given Supplier . |
static ApplicationContextFactory |
ofContextClass(java.lang.Class<? extends org.springframework.context.ConfigurableApplicationContext> contextClass)
Creates an
ApplicationContextFactory that will create contexts by
instantiating the given contextClass through its primary constructor. |
static final ApplicationContextFactory DEFAULT
ApplicationContextFactory
implementation that will create an
appropriate context for the WebApplicationType
.default java.lang.Class<? extends org.springframework.core.env.ConfigurableEnvironment> getEnvironmentType(WebApplicationType webApplicationType)
Environment
type expected to be set on the
created
application context. The result of this
method can be used to convert an existing environment instance to the correct type.webApplicationType
- the web application typenull
to use the defaultdefault org.springframework.core.env.ConfigurableEnvironment createEnvironment(WebApplicationType webApplicationType)
Environment
to be set on the
created
application context. The result of this
method must match the type returned by
getEnvironmentType(WebApplicationType)
.webApplicationType
- the web application typenull
to use the defaultorg.springframework.context.ConfigurableApplicationContext create(WebApplicationType webApplicationType)
webApplicationType
- the web application typestatic ApplicationContextFactory ofContextClass(java.lang.Class<? extends org.springframework.context.ConfigurableApplicationContext> contextClass)
ApplicationContextFactory
that will create contexts by
instantiating the given contextClass
through its primary constructor.contextClass
- the context classBeanUtils.instantiateClass(Class)
static ApplicationContextFactory of(java.util.function.Supplier<org.springframework.context.ConfigurableApplicationContext> supplier)
ApplicationContextFactory
that will create contexts by calling
the given Supplier
.supplier
- the context supplier, for example
AnnotationConfigApplicationContext::new