users@ejb-spec.java.net

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

From: Pete Muir <pmuir_at_bleepbleep.org.uk>
Date: Tue, 27 Nov 2012 12:50:40 +0000

Yes.

On 27 Nov 2012, at 12:48, Mark Struberg wrote:

> I'm not sure if it's a good idea to introduce yet another Scope annotation. I need to think hard about that.
> At the very core javax.ejb.Stateless IS a scope annotation in exactly that sense already.
> All I was initially asking for is that EJB makes it more clear that @Stateless is not only some random marker annotation but a must be interpreted as JSR-330 scope (even without having a @Scoped annotation).
>
> Imo this is not a technical problem at all. The main problem is that our Bean<T> [1] interface (and a few others) has a getScope() method which must return a Scope. Currently we return @Dependent.class for EJBs, but that is obviously wrong. We cannot easily define to just return javax.ejb.Stateless.class in the CDI spec as @Stateless is not a Scope.
>
> This is mainly for Extension developers. And since EJB and CDI moves more and more together we see increased usage of CDI Extensions for tweaking EJBs!
>
> Pete, is this summary correct?
>
> LieGrue,
> strub
>
>
>
> [1] http://docs.oracle.com/javaee/6/api/javax/enterprise/inject/spi/Bean.html
>
>
> PS: an own @PoolScoped annotation would allow to introduce own EJB-like Contexts without Transaction, EJB Security and all other sorts of stuff. Is this good or bad?
>
>
> ----- Original Message -----
>> From: Pete Muir <pmuir_at_bleepbleep.org.uk>
>> To: marina.vatkina_at_oracle.com
>> Cc: jsr345-experts_at_ejb-spec.java.net; Mark Struberg <struberg_at_yahoo.de>; ejb-users <users_at_ejb-spec.java.net>
>> Sent: Wednesday, November 21, 2012 3:20 PM
>> Subject: Re: [ejb-spec users] [jsr345-experts] Re: Re: Question regarding CDI Scope for @Stateless beans
>>
>>
>> On 21 Nov 2012, at 00:13, Marina Vatkina wrote:
>>
>>> Pete Muir wrote:
>>>> 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.
>>>>
>>>
>>> It'll be a CDI EG call, but @PoolScoped can be later applied to some
>> e.g. pooled beans, while @Stateless will stay alone forever.
>>
>> Well yes, this could be a good opportunity to "fix" the name of SLSBs
>> to more accurately reflect what they are (pooled beans).
>>
>>>
>>> -marina
>>>> 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
>>>>>>>>>
>>>>>>>>>
>>>>>>
>>>>
>>>>
>>