Clarification on handling of HTTP calls, multi-threading and dependency injection

@KoenDG,

To do some clarification on the singleton aspects. I’m seeing the code you linked here: Tracing, part 2. More specifically, I’m looking at this. So, in Java, when composing actions (extends Action.Simple, for example) the action composition won’t be a singleton. Even if controllers are singletons, and I think that even if you annotate BeforeControllerAction with @Singleton, Play will create a new instance for each call.

But that has nothing to do with the thread pool.

A possible workaround is to use a filter and routes modifier tags if you don’t want to trace all routes. You will end up with routes like:

+ trace
POST /api/foo/bar ApiController.foobar

And in your filter, you can inspect request.attrs() and only start a trace if the attribute is present.

Best.