Skip to content

benjaminparker/play-inject

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

No packages published