users@jersey.java.net

Re: [Jersey] Naming: _at_Singleton and _at_PerRequest

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 29 Dec 2009 10:42:22 +0100

On Dec 21, 2009, at 6:53 PM, Casper Bang wrote:

> Just found out about @Singleton and @PerRequest. In light of
> transparency/familiarity, is there a good reason for these not to be
> named @Application and @Request respectfully? It seems like
> Application
>> Session > Request > ThreadLocal, is a well established naming
> standard regarding scopes in web frameworks.
>

I agree that Singleton could be better named as PerApplication
(keeping the appropriate Jersey-naming). Can you log an issue to add
that and deprecate @Singleton?


> Or even better, @Scope(ResourceScope.APPLICATION) and
> @Scope(ResourceScope.REQUEST) as that would tie them together a
> little.

The current way it works is that the scope-based annotations are
annotated with a meta-annotation that references a class that supports
the scope.


> Semantically they are mutually exclusive even though Jersey currently
> allows both to be used on the same resource (which one takes
> precedence
> and why?).
>

Tis a bug, having more than one should result in a deployment error.
Can you log an issue?

Currently the annotation that takes precedence will be that which
occurs first (i am not sure if the order of annotations declared in
the source is preserved in byte code).

Paul.