Package io.bootique.di
Class DIBootstrap.InjectorBuilder
java.lang.Object
io.bootique.di.DIBootstrap.InjectorBuilder
- Enclosing class:
- DIBootstrap
Injector builder that allows to configure injector
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Build injector with provided options.Allow only declared overrides.Use singleton scope for bindings by default, otherwise no scope will be used.Disable dynamic (i.e.Disable auto-proxy creation for simple circular dependencies resolutionDisable detailed injection trace (e.g.Enable injection into methods.Set custom exception provider.withInjectAnnotationPredicate(Predicate<AccessibleObject> injectPredicate) Set custom inject predicate.withProviderPredicate(Predicate<Type> providerPredicate) Set custom predicate for Provider type.withProviderWrapper(Function<javax.inject.Provider<T>, javax.inject.Provider<T>> providerFunction) Set custom provider implementation.withProvidesMethodPredicate(Predicate<Method> providesMethodPredicate) Set custom predicate for methods in modules that should be used as providers.withQualifierPredicate(Predicate<Class<? extends Annotation>> qualifierPredicate) Set custom predicate for qualifying annotations.withSingletonPredicate(Predicate<AnnotatedElement> singletonPredicate) Set custom singleton scope predicate.
-
Method Details
-
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
Allow only declared overrides. Disabled by default, all overrides allowed.- Returns:
- this
-
defaultSingletonScope
Use singleton scope for bindings by default, otherwise no scope will be used.- Returns:
- this
-
enableMethodInjection
Enable injection into methods. Disabled by default.- Returns:
- this
-
disableTrace
Disable detailed injection trace (e.g. in production environment). Enabled by default.- Returns:
- this
-
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 forProvidesannotation.- 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 forInjectannotation.- Parameters:
injectPredicate- inject predicate- Returns:
- this
-
withProviderPredicate
Set custom predicate for Provider type. By defaultProviderclass 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 forQualifierannotation.- Parameters:
qualifierPredicate- qualifier predicate- Returns:
- this
-
withSingletonPredicate
public DIBootstrap.InjectorBuilder withSingletonPredicate(Predicate<AnnotatedElement> singletonPredicate) Set custom singleton scope predicate. By default tests forSingletonannotation.- 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 defaultProviderused as is.- Parameters:
providerFunction- provider wrapping function- Returns:
- this
-
withExceptionProvider
public DIBootstrap.InjectorBuilder withExceptionProvider(InjectorPredicates.ExceptionProvider<?> provider) Set custom exception provider. By defaultDIRuntimeException(String, Throwable, Object...)is used.- Parameters:
provider- exception provider- Returns:
- this
-
build
Build injector with provided options.- Returns:
- injector
-