|
|
|
|
@ -29,9 +29,14 @@ import org.springframework.core.env.Environment;
@@ -29,9 +29,14 @@ import org.springframework.core.env.Environment;
|
|
|
|
|
* <p> |
|
|
|
|
* Provides lazy access to singletons that may be expensive to create, or need to be |
|
|
|
|
* shared before the {@link ApplicationContext} is available. |
|
|
|
|
* <p> |
|
|
|
|
* Instances are registered by type. The contact may return {@code null} values when a |
|
|
|
|
* type has been registered but no value is actually supplied. |
|
|
|
|
* |
|
|
|
|
* @author Phillip Webb |
|
|
|
|
* @since 4.0.0 |
|
|
|
|
* @since 2.4.0 |
|
|
|
|
* @see BootstrapRegistry |
|
|
|
|
*/ |
|
|
|
|
public interface BootstrapContext { |
|
|
|
|
|
|
|
|
|
@ -40,7 +45,7 @@ public interface BootstrapContext {
@@ -40,7 +45,7 @@ public interface BootstrapContext {
|
|
|
|
|
* will be created if it hasn't been accessed previously. |
|
|
|
|
* @param <T> the instance type |
|
|
|
|
* @param type the instance type |
|
|
|
|
* @return the instance managed by the context |
|
|
|
|
* @return the instance managed by the context, which may be {@code null} |
|
|
|
|
* @throws IllegalStateException if the type has not been registered |
|
|
|
|
*/ |
|
|
|
|
<T> @Nullable T get(Class<T> type) throws IllegalStateException; |
|
|
|
|
@ -51,7 +56,7 @@ public interface BootstrapContext {
@@ -51,7 +56,7 @@ public interface BootstrapContext {
|
|
|
|
|
* @param <T> the instance type |
|
|
|
|
* @param type the instance type |
|
|
|
|
* @param other the instance to use if the type has not been registered |
|
|
|
|
* @return the instance |
|
|
|
|
* @return the instance, which may be {@code null} |
|
|
|
|
*/ |
|
|
|
|
<T> @Nullable T getOrElse(Class<T> type, @Nullable T other); |
|
|
|
|
|
|
|
|
|
@ -61,7 +66,7 @@ public interface BootstrapContext {
@@ -61,7 +66,7 @@ public interface BootstrapContext {
|
|
|
|
|
* @param <T> the instance type |
|
|
|
|
* @param type the instance type |
|
|
|
|
* @param other a supplier for the instance to use if the type has not been registered |
|
|
|
|
* @return the instance |
|
|
|
|
* @return the instance, which may be {@code null} |
|
|
|
|
*/ |
|
|
|
|
<T> @Nullable T getOrElseSupply(Class<T> type, Supplier<@Nullable T> other); |
|
|
|
|
|
|
|
|
|
@ -72,7 +77,7 @@ public interface BootstrapContext {
@@ -72,7 +77,7 @@ public interface BootstrapContext {
|
|
|
|
|
* @param <X> the exception to throw if the type is not registered |
|
|
|
|
* @param type the instance type |
|
|
|
|
* @param exceptionSupplier the supplier which will return the exception to be thrown |
|
|
|
|
* @return the instance managed by the context |
|
|
|
|
* @return the instance managed by the context, which may be {@code null} |
|
|
|
|
* @throws X if the type has not been registered |
|
|
|
|
* @throws IllegalStateException if the type has not been registered |
|
|
|
|
*/ |
|
|
|
|
|