Hmm... with varargs it will generate 3 bindings, so even though there is one instance it is being initialized three times. This is a bug, I will look into it right away. Thanks for picking it up, Rex!
http://code.google.com/p/google-guice/issues/detail?id=335 Dhanji. 2009/2/14 盛 宁 <[email protected]>: > Sorry, my fault. ServletContainer is also a filter. > My usage: > new ServletModule() { > @Override > protected void configureServlets() { > Map<String, String> initParams = Maps.newHashMap(); > > initParams.put("com.sun.jersey.config.property.packages", > Home.class.getPackage().getName()); > > filterRegex("/(home|logout|login.*)").through(JerseyFilter.class, > initParams); > } > }, > If I announce filterRegex("/home", "/logout", "/login.*"), the @Singleton > JerseyFilter will initiate() 3 times. It this normal? > Thanks, > Rex > > On Feb 14, 2009, at 10:03 AM, Dhanji R. Prasanna wrote: > > You can make a simple wrapper that is HttpServlet, or ask Jersey to update > to using Filters or HttpServlets. > I made the case on JSR-311 that we should not be supporting non-HTTP > servlets and this was accepted by everyone on the EG. So if anything I > consider it a bug in Jersey's implementation. > Dhanji. > > On Sat, Feb 14, 2009 at 12:59 PM, 盛 宁 <[email protected]> wrote: >> >> Cause Jersey's ServletContainer is implementing Servlet but not extending >> HttpServlet. I wrote a filter to delegate it without success. >> Rex >> On Feb 14, 2009, at 8:25 AM, Dhanji R. Prasanna wrote: >> >> This is because GuiceFilter is only intended to work in HttpServlet >> environments. If there was a HttpFilter I would have used that instead (it's >> quite a pain to downcast ServletRequest every time as it is). >> IMO Servlet should be deprecated. >> Dhanji. >> >> On Sat, Feb 14, 2009 at 3:29 AM, Rex Sheng <[email protected]> wrote: >>> >>> Hi, Dhanji, >>> warp-servlet move to google-servlet, so, I post my question here: >>> >>> The FilterKeyBindingBuilder uses javax.servlet.Filter in 'through's, >>> but why ServletKeyBindingBuilder uses javax.servlet.http.HttpServlet? >>> >>> I think it should be javax.servlet.Servlet cause web.xml will work on >>> a javax.servlet.Servlet which not required to be HttpServlet. >>> >>> Thanks, >>> Rex >>> >>> >> >> >> >> >> >> >> > > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
