Interface Builder


public interface Builder
Mutable builder object used when building a bean scope.
  • Method Details

    • newBuilder

      static Builder newBuilder​(List<SuppliedBean> suppliedBeans, List<EnrichBean> enrichBeans)
      Create the root level Builder.
      Parameters:
      suppliedBeans - The list of beans (typically test doubles) supplied when building the context.
      enrichBeans - The list of classes we want to have with mockito spy enhancement
    • isAddBeanFor

      boolean isAddBeanFor​(String name, Class<?>... types)
      Return true if the bean should be created and registered with the context.

      Returning false means there has been a supplied bean already registered and that we should skip the creation and registration for this bean.

      Parameters:
      name - The qualifier name
      types - The types that the bean implements and provides
    • isAddBeanFor

      boolean isAddBeanFor​(Class<?>... types)
      Return true if the bean should be created and registered with the context.

      Returning false means there has been a supplied bean already registered and that we should skip the creation and registration for this bean.

      Parameters:
      types - The types that the bean implements and provides
    • requestScope

      <T> void requestScope​(Class<T> type, RequestScopeProvider<T> provider)
      Register a request scoped bean provider.
      Parameters:
      type - The type of the bean being provided
      provider - The provider
    • requestScope

      <T> void requestScope​(Class<T> type, RequestScopeProvider<T> provider, String name, Class<?>... interfaceTypes)
      Register a request scoped bean provider.
      Parameters:
      name - The qualifier name of the bean being provided
      type - The type of the bean being provided
      provider - The provider
    • register

      <T> T register​(T bean)
      Register the bean instance into the context.
      Parameters:
      bean - The bean instance that has been created.
    • registerPrimary

      <T> T registerPrimary​(T bean)
      Register the bean as a Primary bean.
    • registerSecondary

      <T> T registerSecondary​(T bean)
      Register the bean as a secondary bean.
    • addPostConstruct

      void addPostConstruct​(Runnable runnable)
      Add lifecycle PostConstruct method.
    • addPreDestroy

      void addPreDestroy​(AutoCloseable closeable)
      Add lifecycle PreDestroy method.
    • addInjector

      void addInjector​(Consumer<Builder> injector)
      Add field and method injection.
    • getOptional

      <T> Optional<T> getOptional​(Class<T> cls)
      Get an optional dependency.
    • getOptional

      <T> Optional<T> getOptional​(Class<T> cls, String name)
      Get an optional named dependency.
    • getNullable

      <T> T getNullable​(Class<T> cls)
      Get an optional dependency potentially returning null.
    • getNullable

      <T> T getNullable​(Class<T> cls, String name)
      Get an optional named dependency potentially returning null.
    • getProvider

      <T> jakarta.inject.Provider<T> getProvider​(Class<T> cls)
      Return Provider of T given the type.
    • getProvider

      <T> jakarta.inject.Provider<T> getProvider​(Class<T> cls, String name)
      Return Provider of T given the type and name.
    • get

      <T> T get​(Class<T> cls)
      Get a dependency.
    • get

      <T> T get​(Class<T> cls, String name)
      Get a named dependency.
    • list

      <T> List<T> list​(Class<T> interfaceType)
      Get a list of dependencies for the interface type .
    • set

      <T> Set<T> set​(Class<T> interfaceType)
      Get a set of dependencies for the interface type .
    • build

      BeanScope build​(boolean withShutdownHook)
      Build and return the bean scope.