I just came across a scenario where I had not to choose Play GlobalSettings to execute some tasks on start up of the application, as it is being deprecated in Play 2.5. So as the alternative what we can do to make things happen at the time when application just gets started.
So whatever was done using GlobalSetting.onStart and GlobalSetting.beforeStart needs to be implemented using the dependency injection.
For this, we will just provide the eager binding for the class implementation that needs to perform some tasks just before the application actually gets started.
(Eager binding is used to start up a service when an application starts.)
Then provide those implementations in the constructor of the class for which we have provided eager binding.
So lets start going step by step to replace our onStart/beforeStart implementations with dependency injected class.
Firstly create a class say, MyDBModule which extends AbstractModule in which we will bind the class implementation that will…
View original post 248 more words