In a Scala-based playback application, I am trying to initiate a single-user service without requiring a request to the controller. I followed the directions in the 2.4 API documentation to create a singleton class, and then use the Guice dependency injection library to bind this class as an impatient singleton.
Even with vigorous binding, singleton is still not called until I receive a request through the controller route. Any ideas on what I'm doing wrong?
Module
package models import com.google.inject.AbstractModule import com.google.inject.name.Names class MessageLogModule extends AbstractModule { def configure() = { bind(classOf[MessageLogService]).asEagerSingleton } }
Configuration
play.modules.enabled += "models.MessageLogModule"
Singleton
package models import javax.inject._ @Singleton class MessageLogService {
Launch command
sbt compile run
The above singleton is not called until I issue ...
curl http:
I want MessageLogService to start from the moment the service starts and not wait for the request to hit the controller route.
source share