Package de.simonkerstan.ee.core.di.graph
Class DependencyGraph
java.lang.Object
de.simonkerstan.ee.core.di.graph.DependencyGraph
Graph with all beans and their dependencies.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBean(int priority, Class<?> type, BeanCreationInformation beanCreationInformation) Add a bean to the graph.voidaddDefaultConstructorClass(Class<?> clazz, Class<?>[] interfaces) Add a class with a default constructor to the list of classes with a default constructor.booleanTest whether the graph has unresolved dependencies.Instantiate all beans in the graph.
-
Constructor Details
-
DependencyGraph
public DependencyGraph()
-
-
Method Details
-
addBean
Add a bean to the graph. The graph will automatically resolve all possible types that could be provided by the bean.- Parameters:
priority- Priority of the beantype- Type of the beanbeanCreationInformation- Bean information
-
addDefaultConstructorClass
Add a class with a default constructor to the list of classes with a default constructor.- Parameters:
clazz- Class with a default constructorinterfaces- Directly implemented interfaces of the given class
-
hasUnresolvedDependencies
public boolean hasUnresolvedDependencies()Test whether the graph has unresolved dependencies.- Returns:
trueif there are unresolved dependencies,falseotherwise.
-
instantiateBeans
Instantiate all beans in the graph.- Returns:
- Map of instantiated beans
- Throws:
BeanInstantiationException- If instantiation fails for one of the beans or dependencies are unresolvable
-