users@jersey.java.net

Resource Lifecycle, Providers and Content-Length

From: Jean Aurambault <aurambaj_at_yahoo-inc.com>
Date: Tue, 08 Apr 2008 20:49:50 +0200

Hi,

1) I read this article
http://weblogs.java.net/blog/mhadley/archive/2007/09/new_jersey_feat.html
about resource lifecycle.
If I have well understood, we have the choice between to| PerRequest
|and |Singleton|. The default value should be |PerRequest.|
In my case the default behaviour seems to be singleton and if I put the
PerRequest annotation there is no difference, the resource instantiation
is not done per request. Do I miss something?

2) Another question, about Providers. I see in the examples that we can
use the annotation @Provider instead of using the file META-INF/service
in order to define our specific providers. I would like to now if there
is a specification about the order of the providers in the provider
list. I suppose that providers retreived using annotation are put before
the ones defined in the META-INF/service to allow overloading of default
providers. It should be interessting to be able to define the order at
least between providers added with annotation. Basicaly, I don't want to
iterate the whole list of providers if I know that I will be likely to
use the same one all the time (eg. application with 95% XML requests
and 5% JSON requests). Maybe it doesn't have a big impact on performance
... but I was just wondering :-D

3) Last question about Content-Length in httpHeader response.

When I make a GET on a resource (200) the Content-Length is not set.
When I make a HEAD on the same resource Content-Length is 0.
If I make a HEAD an resource which doesn't exist (404) Content-Length is
952. I have specific content for 404 with variable size. 952 is not the
size of the returned content, because when the content changes
Content-Length stays at 952.

HEAD is supposed to return the Content-Length that a GET request would
have returned. Doesn't it? Is jersey supposed to take in charge the
Content-Length?

Regards,

Jean.