- Type Parameters:
P
- the type provided by the bean to buildT
- the actual type of the bean to build
- All Superinterfaces:
Module.BeanBuilder<T,
Module.ModuleBeanBuilder<P, T>>
- Enclosing class:
Module
A BeanBuilder for creating module Module.Bean
instances.
A module Module.Bean
instance is built from a Supplier
which is used to defer the actual instantiation of the bean. Initialization and destruction operations are invoked once the bean
instance has been created (after dependency injection) and before its destruction respectively.
this.bean = ModuleBeanBuilder
.singleton("bean", () -> {
BeanA beanA = new BeanA(serviceSocket.get());
return beanA;
})
.init(BeanA::init)
.destroy(BeanA::destroy)
.build(this);
- Since:
- 1.0
- Author:
- Jeremy Kuhn
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.inverno.core.v1.Module.BeanBuilder
Module.BeanBuilder.FallibleConsumer<T>
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds the bean.<P> Module.ModuleBeanBuilder
<P, T> Specifies an override that, when present, provides bean instances instead of the builder.static <T> Module.ModuleBeanBuilder
<T, T> Returns a prototype module bean builder.static <T> Module.ModuleBeanBuilder
<T, T> Returns a singleton module bean builder.Methods inherited from interface io.inverno.core.v1.Module.BeanBuilder
destroy, init
-
Method Details
-
singleton
Returns a singleton module bean builder.
Singleton
Module.Bean
s are useful when one single instance of a bean should be injected through the application.- Type Parameters:
T
- the type of the bean to build- Parameters:
beanName
- the bean nameconstructor
- the bean instance supplier- Returns:
- a singleton Bean Builder
-
prototype
Returns a prototype module bean builder.
Prototype
Module.Bean
s are useful when distinct instances of a bean should be injected though the application.- Type Parameters:
T
- the type of the bean to build- Parameters:
beanName
- the bean nameconstructor
- the bean instance supplier- Returns:
- a prototype Bean Builder
-
build
Module.Bean<P> build()Builds the bean.
- Returns:
- a bean
-
override
Specifies an override that, when present, provides bean instances instead of the builder.
- Type Parameters:
P
- the type provided by the bean to build- Parameters:
override
- an optional override- Returns:
- this builder
-