Tutorial by Examples

A typical singleton class : import javax.inject._ @Singleton class BurgersRepository { // implementation goes here } Another class, requiring access to the first one. import javax.inject._ class FastFoodService @Inject() (burgersRepository: BurgersRepository){ // implementation ...
You will often need to access instances of classes from the framework itself (like the WSClient, or the Configuration). You can inject them in your own classes : class ComplexService @Inject()( configuration: Configuration, wsClient: WSClient, applicationLifecycle: ApplicationLifecycle, ...
Basic usage of dependency injection is done by the annotations. When you need to tweak things a little bit, you need custom code to further specify how you want some classes to be instantiated and injected. This code goes in what is called a Module. import com.google.inject.AbstractModule // Pla...

Page 1 of 1