I am trying to learn play framework. I want to implement the lifecycle callbacks of play framework in my application. Now i saw that it can be easily done using GlobalSettings below:
object Global extends GlobalSettings {
override def onStart(app: Application) {
Logger.info("Application has started")
}
override def onStop(app: Application) {
Logger.info("Application shutdown...")
}
}
But it's been deprecated in the play framework(2.5.x). And they are providing eager binding for onStart
callbacks and for onStop
and onError
there are other mechanisms. I looked into the documentation of release 2.5.x and saw a code there like below:
import com.google.inject.AbstractModule
import com.google.inject.name.Names
class Module extends AbstractModule {
def configure() = {
bind(classOf[Hello])
.annotatedWith(Names.named("en"))
.to(classOf[EnglishHello]).asEagerSingleton
bind(classOf[Hello])
.annotatedWith(Names.named("de"))
.to(classOf[GermanHello]).asEagerSingleton
}
}
But unfortunately i couldn't understand it. As using GlobalSettings, it was easy enough to implement the lifecycle callbacks. Suppose that i will just implement a Logger info in the lifecycle callbacks. No complex codes.
How can i implement this for start, stop and error callbacks in 2.5.x ??