What is the intended usage pattern for getControllerInstance on GlobalSettings? Is it possible to use it without a dependency injection framework?
the signature is getControllerInstance[A](controllerClass: Class[A]): A
So, from what I understand, this gets called on any route that is specified with the @
prefix, and you must return an instance of that type of controller (A
). But if A
is the parameterized type of Class
it is subject to type erasure at runtime, correct? How can I know which controller class is being asked for?
I found the way that looks very non-Scala, but works for me.
I absolutely agree that it's ugly and will be happy to see better solution.
Unfortunately it's not possible to use pattern matching here to make this code a little more idiomatic: How can I match classes in a Scala "match" statement?