类 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 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidAdd anApplicationListenerthat will be called with aBootstrapContextClosedEventwhen theBootstrapContextis closed and theApplicationContexthas been prepared.voidclose(ConfigurableApplicationContext applicationContext) Method to be called whenBootstrapContextis closed and theApplicationContextis prepared.<T> TReturn an instance from the context if the type has been registered.<T> TReturn an instance from the context if the type has been registered.<T> TgetOrElseSupply(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.InstanceSupplierfor the given type.<T> booleanisRegistered(Class<T> type) Return if a registration exists for the given type.<T> voidregister(Class<T> type, BootstrapRegistry.InstanceSupplier<T> instanceSupplier) Register a specific type with the registry.<T> voidregisterIfAbsent(Class<T> type, BootstrapRegistry.InstanceSupplier<T> instanceSupplier) Register a specific type with the registry if one is not already present.
-
构造器详细资料
-
DefaultBootstrapContext
public DefaultBootstrapContext()
-
-
方法详细资料
-
register
从接口复制的说明:BootstrapRegistryRegister 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) 从接口复制的说明:BootstrapRegistryRegister 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
从接口复制的说明:BootstrapRegistryReturn if a registration exists for the given type.- 指定者:
isRegistered在接口中BootstrapContext- 指定者:
isRegistered在接口中BootstrapRegistry- 类型参数:
T- the instance type- 参数:
type- the instance type- 返回:
trueif the type has already been registered
-
getRegisteredInstanceSupplier
从接口复制的说明:BootstrapRegistryReturn any existingBootstrapRegistry.InstanceSupplierfor the given type.- 指定者:
getRegisteredInstanceSupplier在接口中BootstrapRegistry- 类型参数:
T- the instance type- 参数:
type- the instance type- 返回:
- the registered
BootstrapRegistry.InstanceSupplierornull
-
addCloseListener
从接口复制的说明:BootstrapRegistryAdd anApplicationListenerthat will be called with aBootstrapContextClosedEventwhen theBootstrapContextis closed and theApplicationContexthas been prepared.- 指定者:
addCloseListener在接口中BootstrapRegistry- 参数:
listener- the listener to add
-
get
从接口复制的说明:BootstrapContextReturn 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
从接口复制的说明:BootstrapContextReturn 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
从接口复制的说明:BootstrapContextReturn 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 从接口复制的说明:BootstrapContextReturn 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 whenBootstrapContextis closed and theApplicationContextis prepared.- 参数:
applicationContext- the prepared context
-