类 DefaultBootstrapContext
java.lang.Object
org.springframework.boot.DefaultBootstrapContext
Default
ConfigurableBootstrapContext
implementation.- 从以下版本开始:
- 2.4.0
- 作者:
- Phillip Webb
-
嵌套类概要
从接口继承的嵌套类/接口 org.springframework.boot.BootstrapRegistry
BootstrapRegistry.InstanceSupplier<T>, BootstrapRegistry.Scope
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明void
Add anApplicationListener
that will be called with aBootstrapContextClosedEvent
when theBootstrapContext
is closed and theApplicationContext
has been prepared.void
close
(ConfigurableApplicationContext applicationContext) Method to be called whenBootstrapContext
is closed and theApplicationContext
is prepared.<T> T
Return an instance from the context if the type has been registered.<T> T
Return an instance from the context if the type has been registered.<T> T
getOrElseSupply
(Class<T> type, Supplier<T> other) Return an instance from the context if the type has been registered.<T,
X extends Throwable>
TgetOrElseThrow
(Class<T> type, Supplier<? extends X> exceptionSupplier) Return an instance from the context if the type has been registered.getRegisteredInstanceSupplier
(Class<T> type) Return any existingBootstrapRegistry.InstanceSupplier
for the given type.<T> boolean
isRegistered
(Class<T> type) Return if a registration exists for the given type.<T> void
register
(Class<T> type, BootstrapRegistry.InstanceSupplier<T> instanceSupplier) Register a specific type with the registry.<T> void
registerIfAbsent
(Class<T> type, BootstrapRegistry.InstanceSupplier<T> instanceSupplier) Register a specific type with the registry if one is not already present.
-
构造器详细资料
-
DefaultBootstrapContext
public DefaultBootstrapContext()
-
-
方法详细资料
-
register
从接口复制的说明:BootstrapRegistry
Register a specific type with the registry. If the specified type has already been registered and has not been obtained as asingleton
, it will be replaced.- 指定者:
register
在接口中BootstrapRegistry
- 类型参数:
T
- the instance type- 参数:
type
- the instance typeinstanceSupplier
- the instance supplier
-
registerIfAbsent
public <T> void registerIfAbsent(Class<T> type, BootstrapRegistry.InstanceSupplier<T> instanceSupplier) 从接口复制的说明:BootstrapRegistry
Register a specific type with the registry if one is not already present.- 指定者:
registerIfAbsent
在接口中BootstrapRegistry
- 类型参数:
T
- the instance type- 参数:
type
- the instance typeinstanceSupplier
- the instance supplier
-
isRegistered
从接口复制的说明:BootstrapRegistry
Return if a registration exists for the given type.- 指定者:
isRegistered
在接口中BootstrapContext
- 指定者:
isRegistered
在接口中BootstrapRegistry
- 类型参数:
T
- the instance type- 参数:
type
- the instance type- 返回:
true
if the type has already been registered
-
getRegisteredInstanceSupplier
从接口复制的说明:BootstrapRegistry
Return any existingBootstrapRegistry.InstanceSupplier
for the given type.- 指定者:
getRegisteredInstanceSupplier
在接口中BootstrapRegistry
- 类型参数:
T
- the instance type- 参数:
type
- the instance type- 返回:
- the registered
BootstrapRegistry.InstanceSupplier
ornull
-
addCloseListener
从接口复制的说明:BootstrapRegistry
Add anApplicationListener
that will be called with aBootstrapContextClosedEvent
when theBootstrapContext
is closed and theApplicationContext
has been prepared.- 指定者:
addCloseListener
在接口中BootstrapRegistry
- 参数:
listener
- the listener to add
-
get
从接口复制的说明:BootstrapContext
Return an instance from the context if the type has been registered. The instance will be created if it hasn't been accessed previously.- 指定者:
get
在接口中BootstrapContext
- 类型参数:
T
- the instance type- 参数:
type
- the instance type- 返回:
- the instance managed by the context
- 抛出:
IllegalStateException
- if the type has not been registered
-
getOrElse
从接口复制的说明:BootstrapContext
Return an instance from the context if the type has been registered. The instance will be created if it hasn't been accessed previously.- 指定者:
getOrElse
在接口中BootstrapContext
- 类型参数:
T
- the instance type- 参数:
type
- the instance typeother
- the instance to use if the type has not been registered- 返回:
- the instance
-
getOrElseSupply
从接口复制的说明:BootstrapContext
Return an instance from the context if the type has been registered. The instance will be created if it hasn't been accessed previously.- 指定者:
getOrElseSupply
在接口中BootstrapContext
- 类型参数:
T
- the instance type- 参数:
type
- the instance typeother
- a supplier for the instance to use if the type has not been registered- 返回:
- the instance
-
getOrElseThrow
public <T,X extends Throwable> T getOrElseThrow(Class<T> type, Supplier<? extends X> exceptionSupplier) throws X 从接口复制的说明:BootstrapContext
Return an instance from the context if the type has been registered. The instance will be created if it hasn't been accessed previously.- 指定者:
getOrElseThrow
在接口中BootstrapContext
- 类型参数:
T
- the instance typeX
- the exception to throw if the type is not registered- 参数:
type
- the instance typeexceptionSupplier
- the supplier which will return the exception to be thrown- 返回:
- the instance managed by the context
- 抛出:
X
- if the type has not been registered
-
close
Method to be called whenBootstrapContext
is closed and theApplicationContext
is prepared.- 参数:
applicationContext
- the prepared context
-