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,
cacheApi: CacheApi,
actorSystem: ActorSystem,
executionContext: ExecutionContext
) {
// Implementation goes here
// you can use all the injected classes :
//
// configuration to read your .conf files
// wsClient to make HTTP requests
// applicationLifecycle to register stuff to do when the app shutdowns
// cacheApi to use a cache system
// actorSystem to use AKKA
// executionContext to work with Futures
}
Some, like the ExecutionContext, will likely more easy to use if they're imported as implicit. Just add them in a second parameter list in the constructor :
class ComplexService @Inject()(
configuration: Configuration,
wsClient: WSClient
)(implicit executionContext: ExecutionContext) {
// Implementation goes here
// you can still use the injected classes
// and executionContext is imported as an implicit argument for the whole class
}