Where are the controller components?

837 views Asked by At

I'm trying to move to compile-time dependency injection using Play Framework 2.6 in Java. My reading of the Play 2.6 Migration Guide under "Scala Controller Changes", leads me to believe that I should pass an instance of ControllerComponents into my controller classes; but I can't find a method that provides those components.

play.api.BuiltInComponentsFromContext defines a controllerComponents() method, but the Java version of that class, play.BuiltInComponentsFromContext, does not.

What is going on?

Under "Using Dependency Injection" in the Play 2.6 (Java) documentation, it talks about overriding javaHandlerComponents in BuiltInComponents. OK fine, but does that mean I have to define all of my actions as separate classes? Can I not use Controller classes if I want to do compile-time dependency injection in Java?

1

There are 1 answers

0
David On BEST ANSWER

The section in Play 2.6 Migration Guide entitled "Scala Controller Changes" is properly named: it applies only to controllers written in Scala. Use the same action composition approach that you've used pre-2.6.