Minimalistic example without modules.
The code in DaggerGarage.java is like handwritten code.
@Override
public Car car() {
return new Car(new Engine());}
-
Module - set of dependencies
-
Enables tests
-
Binds is done in compile time (Garage.java)
-
Provides is injected in runtime (TestGarage.java)
-
provider - jsr-330
- SessionScope - SessionData and SessionManager is in same scope so constructor works
- DBClient is in different scope so we can inject
- DoublecheckProvider ensures that ut is same object
- Singleton is just a scope
- Communicate with external framework through factories
- bindsinto
- Object gets created on get call
- Demonstrate inject