接口 BootstrapContext

所有已知子接口:
ConfigurableBootstrapContext
所有已知实现类:
DefaultBootstrapContext

public interface BootstrapContext
A simple bootstrap context that is available during startup and 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.

从以下版本开始:
2.4.0
作者:
Phillip Webb
  • 方法概要

    修饰符和类型
    方法
    说明
    <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>
    T
    getOrElseThrow(Class<T> type, Supplier<? extends X> exceptionSupplier)
    Return an instance from the context if the type has been registered.
    <T> boolean
    Return if a registration exists for the given type.
  • 方法详细资料

    • get

      <T> T get(Class<T> type) throws IllegalStateException
      Return an instance from the context if the type has been registered. The instance will be created if it hasn't been accessed previously.
      类型参数:
      T - the instance type
      参数:
      type - the instance type
      返回:
      the instance managed by the context
      抛出:
      IllegalStateException - if the type has not been registered
    • getOrElse

      <T> T getOrElse(Class<T> type, T other)
      Return an instance from the context if the type has been registered. The instance will be created if it hasn't been accessed previously.
      类型参数:
      T - the instance type
      参数:
      type - the instance type
      other - the instance to use if the type has not been registered
      返回:
      the instance
    • getOrElseSupply

      <T> T getOrElseSupply(Class<T> type, Supplier<T> other)
      Return an instance from the context if the type has been registered. The instance will be created if it hasn't been accessed previously.
      类型参数:
      T - the instance type
      参数:
      type - the instance type
      other - a supplier for the instance to use if the type has not been registered
      返回:
      the instance
    • getOrElseThrow

      <T, X extends Throwable> T getOrElseThrow(Class<T> type, Supplier<? extends X> exceptionSupplier) throws X
      Return an instance from the context if the type has been registered. The instance will be created if it hasn't been accessed previously.
      类型参数:
      T - the instance type
      X - the exception to throw if the type is not registered
      参数:
      type - the instance type
      exceptionSupplier - the supplier which will return the exception to be thrown
      返回:
      the instance managed by the context
      抛出:
      X - if the type has not been registered
      IllegalStateException - if the type has not been registered
    • isRegistered

      <T> boolean isRegistered(Class<T> type)
      Return if a registration exists for the given type.
      类型参数:
      T - the instance type
      参数:
      type - the instance type
      返回:
      true if the type has already been registered