dev@grizzly.java.net

Grizzly 2.2 ServletHandler changes

From: Andreas Kohn <andreas.kohn_at_fredhopper.com>
Date: Wed, 21 Dec 2011 20:47:53 +0100

Hi,

congratulations to your new release :)

I tried upgrading from 2.1.7 to 2.2, and found that the following code
now longer compiles:

  HttpServlet servlet = ...;
  ServletHandler handler = new ServletHandler();
  handler.setServletInstance(servlet);


1) ServletHandler#<init>() now needs a grizzly-specific
   ServletConfigImpl instance, which in turn requires a grizzly-specific
   WebappContext.

   Is there any specific reason for needing a ServletConfigImpl, rather
   than requiring any instance implementing javax.servlet.ServletConfig?

2) #setServletInstance() is no longer visible, is there any reason for
   that?


Both of these changes were done as part of commit 5e5da223, "Initial cut
of the http-servlet rework".


I've now replaced my code with:

  private static class GrizzlyServletHandler extends ServletHandler {
    public GrizzlyServletHandler(Servlet s, WebappContext c) {
      super(new ServletConfigImpl(c) {});
      setServletInstance(s);
    }
  }

  ... later ...
  ServletHandler handler = new GrizzlyServletHandler(servlet, new
WebappContext("my nice name"));



Is this the "correct" way of creating a servlet handler in grizzly 2.2?

Regards,
--
Andreas
-- 
Never attribute to malice that which can be adequately explained by
stupidity.                                        -- Hanlon's Razor