dev@jsr311.java.net

Re: JSR311: _at_Target of FIELD for _at_*Param annotations

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Mon, 10 Mar 2008 11:27:31 -0400

On Mar 10, 2008, at 10:15 AM, Stephan Koops wrote:

> Hello Marc,
>> The key word is singleton. If a resource class is a singleton then
>> you only have one instance. For performance that instance needs to
>> be reentrant. If you just inject an int then all threads servicing
>> concurrent requests will see the same value. Also injection only
>> happens at object creation time so only values from the first
>> request are injected. See the problem ?
> Yes, I see that, for the case, that the resource classes are
> singeltons.
> But the specification says, that "A new resource class instance is
> created for each request to that resource." (section "Resource
> Classes", subsection "Lifecycle and Environment"). If a new instance
> is newly created for every HTTP request, than it's not a singelton.
> Or do I miss something?

Good catch. I think that per-request should be the default lifecycle
but we shouldn't prevent others like singleton being used. E.g. an
implementation that defers to Spring for resource class instantiation
should be able to use any of the Spring-defined lifecyles.

Marc.

---
Marc Hadley <marc.hadley at sun.com>
CTO Office, Sun Microsystems.