Advanced Topics

Tutorials

Books

You are viewing the documentation for the 2.2.0 release in the 2.2.x series of releases. The latest stable release series is 2.8.x.

By default Play binds URLs to controller methods statically, that is, Controller instances are created by the framework and then the appropriate static method is invoked depending on the given URL. In certain situations, however, you may want to manage controller creation and that’s when the new routing syntax comes handy.

Route definitions starting with @ will be managed by play.GlobalSettings#getControllerInstance method, so given the following route definition:

GET / @controllers.Application.index()

Play will invoke play.GlobalSettings#getControllerInstance which in return will provide an instance of controllers.Application (by default this is happening via controllers.Application’s default constructor). Therefore, if you want to manage controller class instantiation either via a dependency injection framework or manually you can do so by overriding getControllerInstance in your application’s Global class.