接口 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 ApplicationContextFactoryA defaultApplicationContextFactoryimplementation that will create an appropriate context for theWebApplicationType. -
方法概要
修饰符和类型方法说明create(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.
-
字段详细资料
-
DEFAULT
A defaultApplicationContextFactoryimplementation that will create an appropriate context for theWebApplicationType.
-
-
方法详细资料
-
getEnvironmentType
default 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.- 参数:
webApplicationType- the web application type- 返回:
- the expected application context type or
nullto use the default - 从以下版本开始:
- 2.6.14
-
createEnvironment
Create a newEnvironmentto be set on thecreatedapplication context. The result of this method must match the type returned bygetEnvironmentType(WebApplicationType).- 参数:
webApplicationType- the web application type- 返回:
- an environment instance or
nullto 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 anApplicationContextFactorythat will create contexts by instantiating the givencontextClassthrough its primary constructor.- 参数:
contextClass- the context class- 返回:
- the factory that will instantiate the context class
- 另请参阅:
-
of
Creates anApplicationContextFactorythat will create contexts by calling the givenSupplier.- 参数:
supplier- the context supplier, for exampleAnnotationConfigApplicationContext::new- 返回:
- the factory that will instantiate the context class
-