mrszj / google-guice

Automatically exported from code.google.com/p/google-guice
Apache License 2.0
0 stars 0 forks source link

Patch: DefaultGuiceServletContextListener #668

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I have the same exact GuiceServletContextListener in every web project I've 
ever worked on lately.  Rather than continue to copy/paste the code into each 
new project I work on, I thought I should put it in a common library =)

My typical pattern is something along the lines of:
    Injector injector = Guice.createInjector(
        new ServletModule(),
        new Struts2GuicePluginModule(),
        new MyModule());
    Server server = injector.getInstance(Server.class);
    server.run();

With this setup it doesn't make sense to create the Injector in the 
GuiceServletContextListener.  I think that design really only exists for 
running inside of application containers and not for embedded servers like 
Jetty, GSE, etc.  Hopefully this file can be checked in and others running 
embedded servers find it helpful.

Original issue reported on code.google.com by benjamin...@gmail.com on 15 Nov 2011 at 8:12

Attachments: