Package org.springframework.boot
Class DefaultBootstrapContext
java.lang.Object
org.springframework.boot.DefaultBootstrapContext
- All Implemented Interfaces:
- BootstrapContext,- BootstrapRegistry,- ConfigurableBootstrapContext
Default 
ConfigurableBootstrapContext implementation.- Since:
- 2.4.0
- Author:
- Phillip Webb
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.springframework.boot.BootstrapRegistryBootstrapRegistry.InstanceSupplier<T>, BootstrapRegistry.Scope
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidAdd 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.
- 
Constructor Details- 
DefaultBootstrapContextpublic DefaultBootstrapContext()
 
- 
- 
Method Details- 
registerDescription copied from interface: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.- Specified by:
- registerin interface- BootstrapRegistry
- Type Parameters:
- T- the instance type
- Parameters:
- type- the instance type
- instanceSupplier- the instance supplier
 
- 
registerIfAbsentpublic <T> void registerIfAbsent(Class<T> type, BootstrapRegistry.InstanceSupplier<T> instanceSupplier) Description copied from interface:BootstrapRegistryRegister a specific type with the registry if one is not already present.- Specified by:
- registerIfAbsentin interface- BootstrapRegistry
- Type Parameters:
- T- the instance type
- Parameters:
- type- the instance type
- instanceSupplier- the instance supplier
 
- 
isRegisteredDescription copied from interface:BootstrapRegistryReturn if a registration exists for the given type.- Specified by:
- isRegisteredin interface- BootstrapContext
- Specified by:
- isRegisteredin interface- BootstrapRegistry
- Type Parameters:
- T- the instance type
- Parameters:
- type- the instance type
- Returns:
- trueif the type has already been registered
 
- 
getRegisteredInstanceSupplierDescription copied from interface:BootstrapRegistryReturn any existingBootstrapRegistry.InstanceSupplierfor the given type.- Specified by:
- getRegisteredInstanceSupplierin interface- BootstrapRegistry
- Type Parameters:
- T- the instance type
- Parameters:
- type- the instance type
- Returns:
- the registered BootstrapRegistry.InstanceSupplierornull
 
- 
addCloseListenerDescription copied from interface:BootstrapRegistryAdd anApplicationListenerthat will be called with aBootstrapContextClosedEventwhen theBootstrapContextis closed and theApplicationContexthas been prepared.- Specified by:
- addCloseListenerin interface- BootstrapRegistry
- Parameters:
- listener- the listener to add
 
- 
getDescription copied from interface:BootstrapContextReturn an instance from the context if the type has been registered. The instance will be created if it hasn't been accessed previously.- Specified by:
- getin interface- BootstrapContext
- Type Parameters:
- T- the instance type
- Parameters:
- type- the instance type
- Returns:
- the instance managed by the context
- Throws:
- IllegalStateException- if the type has not been registered
 
- 
getOrElseDescription copied from interface:BootstrapContextReturn an instance from the context if the type has been registered. The instance will be created if it hasn't been accessed previously.- Specified by:
- getOrElsein interface- BootstrapContext
- Type Parameters:
- T- the instance type
- Parameters:
- type- the instance type
- other- the instance to use if the type has not been registered
- Returns:
- the instance
 
- 
getOrElseSupplyDescription copied from interface:BootstrapContextReturn an instance from the context if the type has been registered. The instance will be created if it hasn't been accessed previously.- Specified by:
- getOrElseSupplyin interface- BootstrapContext
- Type Parameters:
- T- the instance type
- Parameters:
- type- the instance type
- other- a supplier for the instance to use if the type has not been registered
- Returns:
- the instance
 
- 
getOrElseThrowpublic <T,X extends Throwable> T getOrElseThrow(Class<T> type, Supplier<? extends X> exceptionSupplier) throws X Description copied from interface:BootstrapContextReturn an instance from the context if the type has been registered. The instance will be created if it hasn't been accessed previously.- Specified by:
- getOrElseThrowin interface- BootstrapContext
- Type Parameters:
- T- the instance type
- X- the exception to throw if the type is not registered
- Parameters:
- type- the instance type
- exceptionSupplier- the supplier which will return the exception to be thrown
- Returns:
- the instance managed by the context
- Throws:
- X- if the type has not been registered
 
- 
closeMethod to be called whenBootstrapContextis closed and theApplicationContextis prepared.- Parameters:
- applicationContext- the prepared context
 
 
-