OK, maybe I'm being dense and it will all flash for me in a minute,
but it seems like this new feature, while better for an all-Guice, all-
servlet system does not satisfy the same use cases as before.

My web.xml file can't be empty of servlet definitions, because I don't
control the entire file.  I have a couple of servlets that are the
entry point to the fairly self-contained org.restlet world that uses
Guice extensively, but there's plenty of other stuff in web.xml
(legacy to me, important to others) that will never be in the Guice
club and will always use servlets.  (And note that the servlets I have
are just glue to the web.xml world, and I'd rather live without them,
so the ServletModule for Guice is just a piece of glue code to me.)

So I can just put in new ServletModule(){serve("/shoppingcart")...} in
my code, and it will all work as long as nobody uses /shoppingcart in
web.xml?

Thanks to you and Jesse for taking the time to explain this (and other
stuff in the past) to me.
Leigh

On Mar 4, 7:45 pm, "Dhanji R. Prasanna" <[email protected]> wrote:
> Get rid of init() altogether and just constructor inject your servlets.
> Remove them from web.xml and move them to ServletModule:
>
> new ServletModule() {
>   serve("/myservet").with(MyServlet.class);
>
> }
>
> class MyServlet {
>
>   @Inject MyServlet(Dep1 dep...) {
> // etc.
>
> }
>
> Your web.xml should be empty except for the code snippet for GuiceFilter
> (from the wiki tute you linked to).
>
> Dhanji.
>
> On Thu, Mar 5, 2009 at 9:41 AM, Leigh Klotz <[email protected]> wrote:
>
> > I've been using an earlier snapshot and am upgrading to Guice 2
> > prerelease snapshot 20090205.
>
> > I've been relying on injection into servlets happening in the init
> > (ServletConfig) method once super.init(servletConfig) has been
> > called.  I did not previously use the GuiceFilter in web.xml, as I did
> > not use Request or Session annotations.
>
> > I noticed that com.google.inject.servlet.InjectedHttpServlet went away
> > and so I removed it, and put in th GuiceFilter and applied it to "/*",
> > as described inhttp://code.google.com/p/google-guice/wiki/Servlets
>
> > However, I'm finding that the servlets are not being injected during
> > init.  I'm not surprised, since I don't see how the servlet instances
> > can be found through a filter in web.xml during init, and there's no
> > Guice code in the init() hierarchy any more.
>
> > What's the recommended path for me to make use of Guice in servlets
> > during their init?
>
> > Leigh.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to