benjaminparker/play-inject
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
An example of managed controller instantiation in Play 2.1 ========================================================== Using the @ symbol before the controller in the routes file and a custom Global object specified in application.conf we are able to have control over the instantiation of controller instances. This is achieved by overriding the getControllerInstance function of GlobalSettings trait. I use a map in this example but you could easily defer this to your dependency injection framework of choice. Then we can switch our services for stub versions by simply overriding the controller instance in the test version of our Global object. This allows for easy switching of real for fake services in integration tests.
About
An example of using Play 2.1 managed controller class instantiation. This allows us to inject stub implementations of services in tests
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published