I'm using the cake pattern for injecting dependencies between components in a play 2.2.1 application. Application is composed of play controllers and we use a custom ActionBuilder
to open our DB session. We currently pass that DB session all the way back to our model layer through the controller and DAO layers as implicit argument. (ActionBuilder -> Controller -> DAO -> Slick Model)
I use play-slick for slick integration and try to use a DAO approach to encapsulate access to our slick models. Our DAOs have several function definitions like findById(id: Int)(implicit s: Session): Option[Entity]
. I would like to avoid that implicit session parameter in every single function definition by injecting a DBSession-retrieving component. This component would be invoked inside the DAO function blocks everytime to retrieve the current request db session.
Coming from the Java and Spring world, I don't know exactly how to achieve that given that I probably can't rely on any ThreadLocal scoped proxy.
Any idea how I would be able to achieve that? Is this a good or bad idea?