Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Force init-on-startup for embedder jetty servlets

Hi,

I'm using embedded Jetty (6.1.26), and would like a servlet to start right when the server is starting up - rather than the lazy initialization upon request.
I tried different approaches none succeeded.
Original code looks like this:

Server server = new Server(7000);
Context context = new Context(server, "/", Context.SESSIONS);
context.addServlet(new MyServlet(), "/myServlet/*");
server.start();

This defaults to the lazy initalization. 
In order to force init on start, I tried the following approaches without success:
  • starting the context separately
  • .setInitOrder(0)
  • moved to ServletHolder and call its .start()
  • moved to ServletHandler and use .setInitializeAtStart(true)

Is it possible to force such init-on-startup?
If so, I would appreciate any clues.

Thanks,
Gilad Barkai.

Back to the top