eager instantiation of singletons

23 views
Skip to first unread message

sai prasad veluru

unread,
Jun 14, 2018, 2:14:58 PM6/14/18
to Play Framework [deprecated]
hi can some one help with eager instantiation of singletons(after app starts but before request comes), I have gone through all the earlier discussions, and none of those worked.Things I have tried. 

public class MetricRegistryModule extends AbstractModule {

public static final ALogger LOGGER = Logger.of(MetricRegistryModule.class);
protected void configure() {
bind(AppStartup.class).asEagerSingleton();

Logger.debug("here $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");

}

}

package modules;

import play.Configuration;
import play.Environment;
import play.Logger;
import play.inject.ApplicationLifecycle;
import javax.inject.Inject;
import javax.inject.Singleton;

class AppStartup {
@Inject
public AppStartup(ApplicationLifecycle lifecycle) {

onStart();


}

public void onStart() {

Logger.debug("here #####################################################################################");
}
}


I also tried changing mode from dev to prod.

They did not work as well, can anyone help with this.


Brett

unread,
Jun 18, 2018, 9:40:13 AM6/18/18
to Play Framework [deprecated]
I use the scala version of play but I hope this still applies.  Do you register your module so play knows that it exists?  i.e. in application.conf
Reply all
Reply to author
Forward
0 new messages