Hi Marc,
can you say, when this standard for singelton annotations (or whatever)
is available in Java EE 6? Could it be integrated in JAX-RS 1.0?
I agree with Sergey, that there should be a default way to mark resource
classes as singeltons.
best regards
Stephan
Marc Hadley schrieb:
> I'm glad you brought this up because it reminded me of a change that I
> missed in the 0.9 release:
>
> https://jsr311.dev.java.net/servlets/ReadMsg?list=dev&msgNo=1340
>
> I think that will address your requirement without our needing to add
> a new annotation.
>
> I don't agree with your assertion that root resource classes are
> likely to be singletons, personally I find the use of ctors that
> per-request allows is very handy. Also, even if we added our own
> annotation for singletons that would work in the absence of an IoC
> framework, we can't expect every IoC framework out there to understand
> our annotation so developers will have to add IoC specific annotations
> or configuration as well as our annotation. What's really needed here
> is a standard for IoC and I'm hopeful we'll get there in EE 6 - for
> now I don't want to add anything to the API that will complicate
> integration between JAX-RS and an IoC standard.
>
> Marc.
>
> On Jul 1, 2008, at 12:38 PM, Sergey Beryozkin wrote:
>
>> Hi
>>
>> JAX-RS specification referes to singletons a number of time, that is,
>> a singleton life cycle is given some prominent
>> attention in the specification. Yet, there's no related annotation
>> availbale in the API - different JAX-RS implementations use private
>> techniques to mark a given root resource class as a singleton.
>>
>> My concern is that given that root resources are likely be singletons
>> more often than not, it won't be possible to write even a basic
>> resource implementation which will work reliably (as a singleton)
>> across multiple implementations. As such I'd like to suggest that a
>> common @Singleton annotation is introduced in the API. This way, the
>> (singleton) resource class, injected as a singleton bean by a IOC
>> framework, or instantiated by the runtime (in which case @Singleton
>> will be noticed), will be a true singleton across multiple
>> implementations...
>>
>> Cheers, Sergey