接口 ApplicationContextFactory
- 函数接口:
- 这是一个函数接口, 因此可用作 lambda 表达式或方法引用的赋值目标。
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.- 从以下版本开始:
- 2.4.0
- 作者:
- Andy Wilkinson, Phillip Webb
-
字段概要
字段修饰符和类型字段说明static final ApplicationContextFactory
A defaultApplicationContextFactory
implementation that will create an appropriate context for theWebApplicationType
. -
方法概要
修饰符和类型方法说明create
(WebApplicationType webApplicationType) default ConfigurableEnvironment
createEnvironment
(WebApplicationType webApplicationType) Create a newEnvironment
to be set on thecreated
application context.default Class
<? extends ConfigurableEnvironment> getEnvironmentType
(WebApplicationType webApplicationType) Return theEnvironment
type expected to be set on thecreated
application context.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
through its primary constructor.
-
字段详细资料
-
DEFAULT
A defaultApplicationContextFactory
implementation that will create an appropriate context for theWebApplicationType
.
-
-
方法详细资料
-
getEnvironmentType
default Class<? extends ConfigurableEnvironment> getEnvironmentType(WebApplicationType webApplicationType) Return theEnvironment
type expected to be set on thecreated
application context. The result of this method can be used to convert an existing environment instance to the correct type.- 参数:
webApplicationType
- the web application type- 返回:
- the expected application context type or
null
to use the default - 从以下版本开始:
- 2.6.14
-
createEnvironment
Create a newEnvironment
to be set on thecreated
application context. The result of this method must match the type returned bygetEnvironmentType(WebApplicationType)
.- 参数:
webApplicationType
- the web application type- 返回:
- an environment instance or
null
to use the default - 从以下版本开始:
- 2.6.14
-
create
- 参数:
webApplicationType
- the web application type- 返回:
- the newly created application context
-
ofContextClass
static ApplicationContextFactory ofContextClass(Class<? extends ConfigurableApplicationContext> contextClass) Creates anApplicationContextFactory
that will create contexts by instantiating the givencontextClass
through its primary constructor.- 参数:
contextClass
- the context class- 返回:
- the factory that will instantiate the context class
- 另请参阅:
-
of
Creates anApplicationContextFactory
that will create contexts by calling the givenSupplier
.- 参数:
supplier
- the context supplier, for exampleAnnotationConfigApplicationContext::new
- 返回:
- the factory that will instantiate the context class
-