public class DefaultBootstrapContext extends java.lang.Object implements ConfigurableBootstrapContext
ConfigurableBootstrapContext implementation.BootstrapRegistry.InstanceSupplier<T>, BootstrapRegistry.Scope| Constructor and Description |
|---|
DefaultBootstrapContext() |
| 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. |
void |
close(org.springframework.context.ConfigurableApplicationContext applicationContext)
Method to be called when
BootstrapContext is closed and the
ApplicationContext is prepared. |
<T> T |
get(java.lang.Class<T> type)
Return an instance from the context if the type has been registered.
|
<T> T |
getOrElse(java.lang.Class<T> type,
T other)
Return an instance from the context if the type has been registered.
|
<T> T |
getOrElseSupply(java.lang.Class<T> type,
java.util.function.Supplier<T> other)
Return an instance from the context if the type has been registered.
|
<T,X extends java.lang.Throwable> |
getOrElseThrow(java.lang.Class<T> type,
java.util.function.Supplier<? extends X> exceptionSupplier)
Return an instance from the context if the type has been registered.
|
<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.
|
public <T> void register(java.lang.Class<T> type,
BootstrapRegistry.InstanceSupplier<T> instanceSupplier)
BootstrapRegistrysingleton, it
will be replaced.register in interface BootstrapRegistryT - the instance typetype - the instance typeinstanceSupplier - the instance supplierpublic <T> void registerIfAbsent(java.lang.Class<T> type,
BootstrapRegistry.InstanceSupplier<T> instanceSupplier)
BootstrapRegistryregisterIfAbsent in interface BootstrapRegistryT - the instance typetype - the instance typeinstanceSupplier - the instance supplierpublic <T> boolean isRegistered(java.lang.Class<T> type)
BootstrapRegistryisRegistered in interface BootstrapContextisRegistered in interface BootstrapRegistryT - the instance typetype - the instance typetrue if the type has already been registeredpublic <T> BootstrapRegistry.InstanceSupplier<T> getRegisteredInstanceSupplier(java.lang.Class<T> type)
BootstrapRegistryBootstrapRegistry.InstanceSupplier for the given type.getRegisteredInstanceSupplier in interface BootstrapRegistryT - the instance typetype - the instance typeBootstrapRegistry.InstanceSupplier or nullpublic void addCloseListener(org.springframework.context.ApplicationListener<BootstrapContextClosedEvent> listener)
BootstrapRegistryApplicationListener that will be called with a
BootstrapContextClosedEvent when the BootstrapContext is closed and
the ApplicationContext has been prepared.addCloseListener in interface BootstrapRegistrylistener - the listener to addpublic <T> T get(java.lang.Class<T> type)
throws java.lang.IllegalStateException
BootstrapContextget in interface BootstrapContextT - the instance typetype - the instance typejava.lang.IllegalStateException - if the type has not been registeredpublic <T> T getOrElse(java.lang.Class<T> type,
T other)
BootstrapContextgetOrElse in interface BootstrapContextT - the instance typetype - the instance typeother - the instance to use if the type has not been registeredpublic <T> T getOrElseSupply(java.lang.Class<T> type,
java.util.function.Supplier<T> other)
BootstrapContextgetOrElseSupply in interface BootstrapContextT - the instance typetype - the instance typeother - a supplier for the instance to use if the type has not been registeredpublic <T,X extends java.lang.Throwable> T getOrElseThrow(java.lang.Class<T> type,
java.util.function.Supplier<? extends X> exceptionSupplier)
throws X extends java.lang.Throwable
BootstrapContextgetOrElseThrow in interface BootstrapContextT - the instance typeX - the exception to throw if the type is not registeredtype - the instance typeexceptionSupplier - the supplier which will return the exception to be thrownX - if the type has not been registeredX extends java.lang.Throwablepublic void close(org.springframework.context.ConfigurableApplicationContext applicationContext)
BootstrapContext is closed and the
ApplicationContext is prepared.applicationContext - the prepared context