1

I'm new to accessing Firebase from my backend. My question is where I should instantiate my listeners? If I do it when one of my controller methods are called, then I loose control of the thread that is instantiated when the listener is added to the database reference. I want to keep my code as stateless as possible, so having and boolean hasAddedFirebaseListeners is something I would like to avoid.

Any ideas?

adjuremods
  • 2,938
  • 2
  • 12
  • 17
why_vincent
  • 2,172
  • 9
  • 33
  • 49
  • When do you want to instantiate the listeners ? Is it during application startup ? Or when you receive a request ? – Vasu Nov 06 '16 at 12:29
  • Some listeners should be instantiated during startup and some should be instantiated upon request, but most of the latter will be listening for only one single event. – why_vincent Nov 06 '16 at 15:38
  • why not to use ServletContextListener http://stackoverflow.com/questions/4746041/spring-injecting-a-dependency-into-a-servletcontextlistener – kuhajeyan Nov 07 '16 at 07:09

0 Answers0