users@jersey.java.net

Re: [Jersey] [PATCH] SpringServlet doesn't quite work with Servlet Filters

From: James Strachan <james.strachan_at_gmail.com>
Date: Mon, 16 Feb 2009 13:31:36 +0000

2009/2/16 Paul Sandoz <Paul.Sandoz_at_sun.com>:
>
> On Feb 16, 2009, at 11:37 AM, James Strachan wrote:
>
>> Just a heads up - I spotted this when trying to use SpringServlet as a
>> Servlet Filter and have submitted a fairly minor patch to fix it...
>> https://jersey.dev.java.net/issues/show_bug.cgi?id=217
>>
>> Its a fairly minor issue - mostly due to WebComponent having a
>> different ServletContext field to ServletContainer which should maybe
>> be refactored a little to avoid similar issues surfacing.
>>
>
> Thanks. Doh, that is embarrassing.
>
> I am going to fix this a long with another issue related to Guice
> integration that Gili found [1], which requires that an HTTP servlet
> implementation implement HttpServlet, which IMHO is wrong because Servlet is
> the contract for invocations not HttpServlet and the latter IIUC is not MUST
> requirement.
>
> Given the Guice discussion i doubt the Guice developers will change things.
> So i am going to make ServletContainer re-implement HttpServlet and
> encapsulate WebComponent.

Great stuff thanks!

BTW I spotted one more minor issue; when using the SpringServlet as a
servlet filter, the regex pattern never seems to be initialised.

I had to add this extra if clause into the configure() method of
ServletContainer (which takes a FilterConfig)

        String regex = (String)rc.getProperty(PROPERTY_WEB_PAGE_CONTENT_REGEX);
        if (regex == null || regex.length() == 0) {
            regex = fc.getInitParameter(PROPERTY_WEB_PAGE_CONTENT_REGEX);
        }

as the rc.getProperty() was returning null. Not sure if this is
evidence of other issues when using servlet filters; e.g. should all
the Filter's init parameter values be copied into the ResourceConfig
abstraction or something?

-- 
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://fusesource.com/