Package io.bootique.di.spi
Class DICollectionBuilder<K,E>
- java.lang.Object
-
- io.bootique.di.spi.DICollectionBuilder<K,E>
-
- Type Parameters:
K
- DI key type.E
- Collection element type.
- All Implemented Interfaces:
ScopeBuilder
public abstract class DICollectionBuilder<K,E> extends Object implements ScopeBuilder
A superclass of DI List and Map builders.
-
-
Field Summary
Fields Modifier and Type Field Description protected Key<K>
bindingKey
protected DefaultInjector
injector
-
Constructor Summary
Constructors Constructor Description DICollectionBuilder(Key<K> bindingKey, DefaultInjector injector)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected javax.inject.Provider<E>
createInstanceProvider(E value)
protected javax.inject.Provider<E>
createProviderProvider(Class<? extends javax.inject.Provider<? extends E>> providerType)
protected <SubT extends E>
javax.inject.Provider<SubT>getByKeyProvider(Key<SubT> key)
protected <SubT extends E>
javax.inject.Provider<SubT>getByTypeProvider(Class<SubT> interfaceType)
void
in(Scope scope)
Sets the scope of a bound instance.void
initOnStartup()
Marks this injection point to be triggered early without explicit call toInjector.getInstance(Class)
.void
inSingletonScope()
Sets the scope of a bound instance to singleton.void
withoutScope()
Sets the scope of a bound instance to "no scope".
-
-
-
Field Detail
-
injector
protected final DefaultInjector injector
-
-
Constructor Detail
-
DICollectionBuilder
public DICollectionBuilder(Key<K> bindingKey, DefaultInjector injector)
-
-
Method Detail
-
createProviderProvider
protected javax.inject.Provider<E> createProviderProvider(Class<? extends javax.inject.Provider<? extends E>> providerType)
-
getByTypeProvider
protected <SubT extends E> javax.inject.Provider<SubT> getByTypeProvider(Class<SubT> interfaceType)
-
getByKeyProvider
protected <SubT extends E> javax.inject.Provider<SubT> getByKeyProvider(Key<SubT> key)
-
in
public void in(Scope scope)
Description copied from interface:ScopeBuilder
Sets the scope of a bound instance. This method is used to change the default scope which is a singleton by default to a custom scope.- Specified by:
in
in interfaceScopeBuilder
-
inSingletonScope
public void inSingletonScope()
Description copied from interface:ScopeBuilder
Sets the scope of a bound instance to singleton. Singleton is normally the default.- Specified by:
inSingletonScope
in interfaceScopeBuilder
-
withoutScope
public void withoutScope()
Description copied from interface:ScopeBuilder
Sets the scope of a bound instance to "no scope". This means that a new instance of an object will be created on every call toInjector.getInstance(Class)
or toProvider
of this instance.- Specified by:
withoutScope
in interfaceScopeBuilder
-
initOnStartup
public void initOnStartup()
Description copied from interface:ScopeBuilder
Marks this injection point to be triggered early without explicit call toInjector.getInstance(Class)
. Such service will be created right afterInjector
is fully setup. NOTE: use with caution, as this will effectively create all graph of services that this service depends on.- Specified by:
initOnStartup
in interfaceScopeBuilder
-
-