public interface BootstrapRegistry
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.
BootstrapContext,
ConfigurableBootstrapContext| Modifier and Type | Interface and Description |
|---|---|
static interface |
BootstrapRegistry.InstanceSupplier<T>
Supplier used to provide the actual instance when needed.
|
static class |
BootstrapRegistry.Scope
The scope of an instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addCloseListener(org.springframework.context.ApplicationListener<BootstrapContextClosedEvent> listener)
Add an
ApplicationListener that will be called with a
BootstrapContextClosedEvent when the BootstrapContext is closed and
the ApplicationContext has been prepared. |
<T> BootstrapRegistry.InstanceSupplier<T> |
getRegisteredInstanceSupplier(java.lang.Class<T> type)
Return any existing
BootstrapRegistry.InstanceSupplier for the given type. |
<T> boolean |
isRegistered(java.lang.Class<T> type)
Return if a registration exists for the given type.
|
<T> void |
register(java.lang.Class<T> type,
BootstrapRegistry.InstanceSupplier<T> instanceSupplier)
Register a specific type with the registry.
|
<T> void |
registerIfAbsent(java.lang.Class<T> type,
BootstrapRegistry.InstanceSupplier<T> instanceSupplier)
Register a specific type with the registry if one is not already present.
|
<T> void register(java.lang.Class<T> type,
BootstrapRegistry.InstanceSupplier<T> instanceSupplier)
singleton, it
will be replaced.T - the instance typetype - the instance typeinstanceSupplier - the instance supplier<T> void registerIfAbsent(java.lang.Class<T> type,
BootstrapRegistry.InstanceSupplier<T> instanceSupplier)
T - the instance typetype - the instance typeinstanceSupplier - the instance supplier<T> boolean isRegistered(java.lang.Class<T> type)
T - the instance typetype - the instance typetrue if the type has already been registered<T> BootstrapRegistry.InstanceSupplier<T> getRegisteredInstanceSupplier(java.lang.Class<T> type)
BootstrapRegistry.InstanceSupplier for the given type.T - the instance typetype - the instance typeBootstrapRegistry.InstanceSupplier or nullvoid addCloseListener(org.springframework.context.ApplicationListener<BootstrapContextClosedEvent> listener)
ApplicationListener that will be called with a
BootstrapContextClosedEvent when the BootstrapContext is closed and
the ApplicationContext has been prepared.listener - the listener to add