jsr370-experts@jax-rs-spec.java.net

Re: CDI integration and _at_RequestScoped

From: Santiago Pericas-Geertsen <Santiago.PericasGeertsen_at_oracle.com>
Date: Wed, 18 Feb 2015 11:09:49 -0500

> On Feb 18, 2015, at 10:39 AM, Sergey Beryozkin <sberyozkin_at_talend.com> wrote:
>
> Hi Santiago,
>
> On 18/02/15 14:16, Santiago Pericas-Geertsen wrote:
>> Sergey,
>>
>> The spec clearly states that resource classes are in “per-request” scope by default in a few places. It also states that implementations can support other scopes.
>>
>> If a resource class is a CDI bean, then it should be created by CDI based on the whatever scope annotation it has on it.
>
> Is CDI RequestScoped qualifies at the "other scope" as opposed to a default per-request one where the JAXRS runtime just loads a new instance itself ?
> This is what I'm trying to understand.

 CDI @RequestScoped and per-request are the same: one instance per request. But note that, unlike JAX-RS, @RequestScoped is not the default in CDI, @Dependent is.

>
> If yes, does 'can support other scopes' means 'must’ ?

 No. But the way I see it, if you do integrate with CDI, then you get all the other CDI scopes for free.

— Santiago

>>> On Feb 18, 2015, at 6:27 AM, Sergey Beryozkin <sberyozkin_at_talend.com> wrote:
>>>
>>> Hi
>>>
>>> I've checked the spec and I'm not seeing any guidance re the scope of CDI JAX-RS root resource Beans, it only mentions that "providers or Application subclasses" have to be singleton or application-scoped.
>>>
>>> If a CDI root resource is annotated with @RequestScoped then does it mean the runtime is expected to ensure it is created once per every request ?
>>>
>>> Thanks, Sergey
>>
>