POC project on Dagger2
Employee is dependent on Salary and ContactDetails.
Residence is dependent on Address.
Annotations :
- @Inject : tells the Dagger how to create instances of Employee
- @Module : tells Dagger how to provide dependencies from the dependency graph.
- @Provides :
- @Binds :
- @Component : tells Dagger to generate a container with all the dependencies required to satisfy the types it exposes.
Dependency Injection types :
- Constructor Injection: Injecting the method parameters.
- Field Injection: Injecting the member variable (must not be private).
- Method Injection: Injecting the method parameter.
Order of dependency injection according to JSR330 (Java Specification Requests) :
- Constructor
- Field
- Method