users@jersey.java.net

Re: Abstract servlet adaptor <was> Re: Using HttpServletRequest/HttpServletResponse

From: Aaron Anderson <nickmalthus_at_yahoo.com>
Date: Wed, 19 Sep 2007 10:16:29 -0700 (PDT)

> It seems appropriate for the abstract servlet adaptor to retain this
> functionality by default but yet allow extentions to override:

> /**
> * Create the WebApplication instance.
> * This method may be overridden for servlet adaptors that need to
> * specialize creation.
> */
> protected WebApplication createWebApplication() {
> return WebApplicationFactory.createWebApplication();
> }

> /*
> * Initiate the web application.
> * This method may be overridden for servlet adaptors that need to
> * specialize initiation, for example modifying the features and
> * properties of the ResourceConfig instance or adding further
> * injectables to the WebApplication instance.
> * The overridden method must call WebApplication.initiate or call
> * super.initiate(c, app);
> */
> protected void initiate(ServletConfig servletConfig,
> ResourceConfig c, WebApplication app) {
> app.initiate(this, resourceConfig);
> }

> Would that work for you?

It would work perfectly for my needs. With the property bag support and access
to both ResourceConfig and the WebApplication instances I can configure them
for their runtime environment as needed.

> I think it may be appropriate for the abstract servlet adapter to
> support injection of HttpServletRequest, HttpServletResponse and
> ServletConfig i.e. standard servlet stuff.

Good idea. The spec mandates these must be available in a Servlet environment.

> And for the Jersey
> implementation to support injection of EntityManagerFactory. That way
> it is possible to avoid a dependency on the persistence API jar. Plus the
> persistence stuff may require some more work.

Another great idea. If this dependency was removed then all that would be needed
for running Jersey in a Servlet environment would be the JSR 311 API and Jersey RI jars.
If developers wanted to add injectable persistence support for their resources
they could always extend the Jersey ServletAdaptor instead of the abstract SPI one.
       
---------------------------------
Don't let your dream ride pass you by. Make it a reality with Yahoo! Autos.