Wiring it all up

In the preceding code, we saw a bunch of components with their implementations that declare dependencies to others. We still haven't seen how everything will be used together. By defining our components as traits, we can just mix them in together and they will be available to us. This is how we have done it:

object ApplicationComponentRegistry  extends UserComponent    with DaoComponent    with DatabaseComponent    with MigrationComponent {  override val dao: ApplicationComponentRegistry.Dao = new Dao  override val databaseService: DatabaseService = new H2DatabaseService("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", "", "")  override val migrationService: ApplicationComponentRegistry.MigrationService = new MigrationService  override val userService ...

Get Scala Design Patterns - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.