3

I am developing a GWT application on google app engine and I am looking for the best approach to initialize objects (like singleton, list, shared resources etc). I guess I am looking for something like "Spring application context file"

any ideas?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Muky
  • 3,584
  • 3
  • 19
  • 20
  • 1
    Possible duplicate of [Using special auto start servlet to initialize on startup and share application data](http://stackoverflow.com/questions/3468150/using-special-auto-start-servlet-to-initialize-on-startup-and-share-application) – BalusC Oct 08 '15 at 07:57

2 Answers2

4

What you're looking for is here:

http://code.google.com/appengine/docs/java/config/appconfig.html#Using_a_ServletContextListener

Basically, you're going to make a Servlet Context Listener, which is a part of the servlet API designed for exactly what you're referring to. If you're running this locally, it will run when you start your server. In the app engine environment it should run for every warm up request (to avoid, this, you can use "Always ON", which will be set here: http://code.google.com/appengine/docs/adminconsole/instances.html#Always_On)

Dave
  • 6,141
  • 2
  • 38
  • 65
2

Besides ServletContextListener you can also use <load-on-startup> to mark your normal servlet to be invoked during a warmup request.

Dave W. Smith
  • 24,318
  • 4
  • 40
  • 46
Peter Knego
  • 79,991
  • 11
  • 123
  • 154