users@ejb-spec.java.net

[ejb-spec users] Re: [jsr345-experts] Re: Question regarding CDI Scope for @Stateless beans

From: Pete Muir <pmuir_at_bleepbleep.org.uk>
Date: Tue, 20 Nov 2012 14:30:22 +0000

Marina,

I meant *a* JSR-330 scope, not the default JSR-330 scope :-)

We could introduce a new scope @PoolScoped, however as SLSBs would automatically belong to this scope, and we wouldn't support it for now for other beans, it wouldn't normally be used, so therefore feels like API clutter, when @Stateless already exists.

On 19 Nov 2012, at 20:39, Marina Vatkina wrote:

> Pete,
>
> With JSR-330 scope "the injector creates an instance (by injecting the type's constructor), uses the instance for one injection, and then forgets it", which doesn't either. The instance is either destroyed or pooled.
>
> May be it should be called @Pooled?
>
> -marina
>
> Pete Muir wrote:
>> Another option is for CDI to define that @Stateless is a JSR-330 scope, however, this feels very weird to me.
>>
>> The issue here is purely one of correctness, it wouldn't change any behavior. It's just that right now Stateless EJBs are defined as "dependent" (which normally means their lifecycle depends on the bean into which they are injected), however this is not how they behave! So confusing for a user of CDI + EJB.
>>
>> On 17 Nov 2012, at 01:31, Marina Vatkina wrote:
>>
>>
>>> Hmmm... so far all scopes for the EJBs are defined in the CDI spec. So it would be strange if the EJB spec define scope for one bean type...
>>>
>>> my $.02
>>>
>>> What do others think?
>>>
>>> thanks,
>>> -marina
>>>
>>> Mark Struberg wrote:
>>>
>>>> PS: please note that this does _not_ require to change any code or apply @javax.inject.Scope. This would purely be a textual clarification in the spec.
>>>>
>>>> LieGrue,
>>>> strub
>>>>
>>>>
>>>>
>>>> ----- Original Message -----
>>>>
>>>>> From: Mark Struberg <struberg_at_yahoo.de>
>>>>> To: ejb-users <users_at_ejb-spec.java.net>
>>>>> Cc: Sent: Friday, November 16, 2012 6:02 PM
>>>>> Subject: [ejb-spec users] Question regarding CDI Scope for @Stateless beans
>>>>>
>>>>> Dear EJB EG!
>>>>>
>>>>> We have a question regarding the scope which we should use for @Stateless beans handling in CDI. Currently this is defined as being treated as @Dependent. But this is obviously wrong and got only worded that way to prevent the CDI containers from applying CDI NormalScoped proxies.
>>>>>
>>>>>
>>>>> Please see the discussion so far on our CDI EG issue tracker:
>>>>> https://issues.jboss.org/browse/CDI-278
>>>>>
>>>>> A possible solution would be to define javax.ejb.Stateless as non-normalscoped CDI scope. CDI would *not* apply any client proxies itself that way but we would be able to return javax.ejb.Stateless.class in Bean#getScope() for EJBs.
>>>>>
>>>>> We think this is a good solution but don't like to define this in the CDI spec because this is clearly an EJB related question and we don't like to cross-specify EJB behaviour in the CDI spec.
>>>>>
>>>>> Wdyt? Would that fit into your concept?
>>>>>
>>>>>
>>>>> txs and LieGrue,
>>>>> strub
>>>>>
>>>>>
>>
>>