- Type Parameters:
T
- the actual type of the bean
- All Implemented Interfaces:
Supplier<T>
- Enclosing class:
Module
Interface representing the lifecycle of a bean in a module.
Module.Bean
instances are used within modules during initialization to perform dependency injection in order to defer the actual beans instantiation beans at module startup. Dependency cycles,
missing dependencies and other issues related to dependency injection are normally raised at compile time.
A bean has to be registered in a module before it can be used.
- Since:
- 1.0
- Author:
- Jeremy Kuhn
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
create()
Creates the underlying bean instanceabstract void
destroy()
Destroys the underlying instance.abstract T
doGet()
Returns the supplied bean instance.final T
get()
Returns the requested bean instance while making sure the enclosing module is active.
-
Field Details
-
parent
The module into which the bean is registered. -
name
The bean name.
-
-
Constructor Details
-
Bean
Creates a bean with the specified name.
- Parameters:
name
- the bean name
-
-
Method Details
-
get
Returns the requested bean instance while making sure the enclosing module is active.
In case the enclosing module is not active but one of its ancestors is active, this method starts the enclosing module in order to start modules in their natural order. If no ancestor is active (ie. the enclosing module is not part of a module initialization process), an
IllegalStateException
is thrown.- Specified by:
get
in interfaceSupplier<T>
- Throws:
IllegalStateException
- if the enclosing module is inactive and not part of a module initialization process.
-
doGet
Returns the supplied bean instance.
- Returns:
- a bean instance
-
create
public abstract void create()Creates the underlying bean instance
-
destroy
public abstract void destroy()Destroys the underlying instance.
-