I'm trying to understand play's execution context and exactly how this fits into how I am using play with google guice.
A typical control that I am building looks like:
@Singleton
class MyController @Inject()(myService: MyService) extends Controller {
def show(id: Int) = Action {
val m = myService.getMy(id)
Ok("this is my name " + m.name
}
}
And the MyService is extending a trait that creates the apache tomcat jdbc threadpool like:
trait BaseService {
val ds = LoadApacheJdbcPool.datasource
val db = Database.forDataSource(ds)
}
Now from what I understand this will load in the default execution context as per: http://www.playframework.com/documentation/2.1.0/ThreadPools
play {
akka {
event-handlers = ["akka.event.slf4j.Slf4jEventHandler"]
loglevel = WARNING
actor {
default-dispatcher = {
fork-join-executor {
parallelism-factor = 1.0
parallelism-max = 24
}
}
}
}
}
So what does this mean, under the default settings (above), does this mean there will be up to 24 threads created?
The real question for me is depending on what is going on, how do I get my injected service that creates a jdbc pool (which may or may not have many threads) in its own execution context and not the default on?
I read I could wrap my calls in a future and explicity pass a execution context, but that is for calls on my 'MyService' but that was already injected and created the jdbc pool already.