Class DIBootstrap.InjectorBuilder

java.lang.Object
io.bootique.di.DIBootstrap.InjectorBuilder
Enclosing class:
DIBootstrap

public static class DIBootstrap.InjectorBuilder extends Object
Injector builder that allows to configure injector
  • Method Details

    • disableDynamicBindings

      public DIBootstrap.InjectorBuilder disableDynamicBindings()
      Disable dynamic (i.e. not registered directly in binder) binding resolution. If disabled, Injector will throw in case of the unknown binding. Enabled by default.
      Returns:
      this
    • declaredOverridesOnly

      public DIBootstrap.InjectorBuilder declaredOverridesOnly()
      Allow only declared overrides. Disabled by default, all overrides allowed.
      Returns:
      this
    • defaultSingletonScope

      public DIBootstrap.InjectorBuilder defaultSingletonScope()
      Use singleton scope for bindings by default, otherwise no scope will be used.
      Returns:
      this
    • enableMethodInjection

      public DIBootstrap.InjectorBuilder enableMethodInjection()
      Enable injection into methods. Disabled by default.
      Returns:
      this
    • disableTrace

      public DIBootstrap.InjectorBuilder disableTrace()
      Disable detailed injection trace (e.g. in production environment). Enabled by default.
      Returns:
      this
    • disableProxyCreation

      public DIBootstrap.InjectorBuilder disableProxyCreation()
      Disable auto-proxy creation for simple circular dependencies resolution
      Returns:
      this
    • withProvidesMethodPredicate

      public DIBootstrap.InjectorBuilder withProvidesMethodPredicate(Predicate<Method> providesMethodPredicate)
      Set custom predicate for methods in modules that should be used as providers. Default predicate test methods for Provides annotation.
      Parameters:
      providesMethodPredicate - method predicate
      Returns:
      this
    • withInjectAnnotationPredicate

      public DIBootstrap.InjectorBuilder withInjectAnnotationPredicate(Predicate<AccessibleObject> injectPredicate)
      Set custom inject predicate. Default predicate test constructors, methods and fields for Inject annotation.
      Parameters:
      injectPredicate - inject predicate
      Returns:
      this
    • withProviderPredicate

      public DIBootstrap.InjectorBuilder withProviderPredicate(Predicate<Type> providerPredicate)
      Set custom predicate for Provider type. By default Provider class is used.
      Parameters:
      providerPredicate - provider type predicate
      Returns:
      this
    • withQualifierPredicate

      public DIBootstrap.InjectorBuilder withQualifierPredicate(Predicate<Class<? extends Annotation>> qualifierPredicate)
      Set custom predicate for qualifying annotations. By default tests for Qualifier annotation.
      Parameters:
      qualifierPredicate - qualifier predicate
      Returns:
      this
    • withSingletonPredicate

      public DIBootstrap.InjectorBuilder withSingletonPredicate(Predicate<AnnotatedElement> singletonPredicate)
      Set custom singleton scope predicate. By default tests for Singleton annotation.
      Parameters:
      singletonPredicate - singleton predicate
      Returns:
      this
    • withProviderWrapper

      public <T> DIBootstrap.InjectorBuilder withProviderWrapper(Function<javax.inject.Provider<T>,javax.inject.Provider<T>> providerFunction)
      Set custom provider implementation. By default Provider used as is.
      Parameters:
      providerFunction - provider wrapping function
      Returns:
      this
    • withExceptionProvider

      public DIBootstrap.InjectorBuilder withExceptionProvider(InjectorPredicates.ExceptionProvider<?> provider)
      Set custom exception provider. By default DIRuntimeException(String, Throwable, Object...) is used.
      Parameters:
      provider - exception provider
      Returns:
      this
    • build

      public Injector build()
      Build injector with provided options.
      Returns:
      injector