接口 BootstrapRegistry
- 所有已知子接口:
ConfigurableBootstrapContext
- 所有已知实现类:
DefaultBootstrapContext
public interface BootstrapRegistry
A simple object registry that is available during startup and
Environment
post-processing up to the point that the ApplicationContext
is prepared.
Can be used to register instances that may be expensive to create, or need to be shared
before the ApplicationContext
is available.
The registry uses Class
as a key, meaning that only a single instance of a
given type can be stored.
The addCloseListener(ApplicationListener)
method can be used to add a listener
that can perform actions when BootstrapContext
has been closed and the
ApplicationContext
is fully prepared. For example, an instance may choose to
register itself as a regular Spring bean so that it is available for the application to
use.
- 从以下版本开始:
- 2.4.0
- 作者:
- Phillip Webb
- 另请参阅:
-
嵌套类概要
嵌套类修饰符和类型接口说明static interface
Supplier used to provide the actual instance when needed.static enum
The scope of an instance. -
方法概要
修饰符和类型方法说明void
Add anApplicationListener
that will be called with aBootstrapContextClosedEvent
when theBootstrapContext
is closed and theApplicationContext
has been prepared.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.
-
方法详细资料
-
register
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.- 类型参数:
T
- the instance type- 参数:
type
- the instance typeinstanceSupplier
- the instance supplier
-
registerIfAbsent
Register a specific type with the registry if one is not already present.- 类型参数:
T
- the instance type- 参数:
type
- the instance typeinstanceSupplier
- the instance supplier
-
isRegistered
Return if a registration exists for the given type.- 类型参数:
T
- the instance type- 参数:
type
- the instance type- 返回:
true
if the type has already been registered
-
getRegisteredInstanceSupplier
Return any existingBootstrapRegistry.InstanceSupplier
for the given type.- 类型参数:
T
- the instance type- 参数:
type
- the instance type- 返回:
- the registered
BootstrapRegistry.InstanceSupplier
ornull
-
addCloseListener
Add anApplicationListener
that will be called with aBootstrapContextClosedEvent
when theBootstrapContext
is closed and theApplicationContext
has been prepared.- 参数:
listener
- the listener to add
-