public interface BootstrapContext
Environment
post-processing up to the point that the ApplicationContext
is prepared.
Provides lazy access to singletons that may be expensive to create, or need to be
shared before the ApplicationContext
is available.
Modifier and Type | Method and Description |
---|---|
<T> T |
get(Class<T> type)
Return an instance from the context if the type has been registered.
|
<T> T |
getOrElse(Class<T> type,
T other)
Return an instance from the context if the type has been registered.
|
<T> T |
getOrElseSupply(Class<T> type,
Supplier<T> other)
Return an instance from the context if the type has been registered.
|
<T,X extends Throwable> |
getOrElseThrow(Class<T> type,
Supplier<? extends X> exceptionSupplier)
Return an instance from the context if the type has been registered.
|
<T> boolean |
isRegistered(Class<T> type)
Return if a registration exists for the given type.
|
<T> T get(Class<T> type) throws IllegalStateException
T
- the instance typetype
- the instance typeIllegalStateException
- if the type has not been registered<T> T getOrElse(Class<T> type, T other)
T
- the instance typetype
- the instance typeother
- the instance to use if the type has not been registered<T> T getOrElseSupply(Class<T> type, Supplier<T> other)
T
- the instance typetype
- the instance typeother
- a supplier for the instance to use if the type has not been registered<T,X extends Throwable> T getOrElseThrow(Class<T> type, Supplier<? extends X> exceptionSupplier) throws X extends Throwable
T
- 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 registeredIllegalStateException
- if the type has not been registeredX extends Throwable
<T> boolean isRegistered(Class<T> type)
T
- the instance typetype
- the instance typetrue
if the type has already been registered