users@javaee-spec.java.net

[javaee-spec users] Re: allowing stereotypes to be used more widely

From: Bill Shannon <bill.shannon_at_oracle.com>
Date: Mon, 19 Nov 2012 19:26:04 -0800

Marina Vatkina wrote on 11/19/2012 05:56 PM:
> Bill Shannon wrote:
>> Marina Vatkina wrote on 11/19/12 15:46:
>>
>>> Pete,
>>>
>>> Pete Muir wrote:
>>>
>>>> I was on the fence for a long time, however discussing with the CDI EG and
>>>> colleagues made it clear there was little support once we went through the
>>>> possible confusion that can arise. The CDI EG also agrees with me here :-)
>>>>
>>>> Here is the point which we think kills the idea. If you define this stereotype
>>>> in CDI, with the support proposed for all Java EE specs:
>>>>
>>>> @Stereotype
>>>> @RequestScoped
>>>> @Stateless
>>>> public @interface MyStereotype {}
>>>>
>>>> And define this bean:
>>>>
>>>> @MyStereotype public class MyBean {}
>>>>
>>>> you end up with a request scoped SLSB.
>>>>
>>> How is it different from:
>>>
>>> @RequestScoped
>>> @Stateless
>>> public class MyBean {}
>>>
>>
>> If we implemented it, it wouldn't be any different. That's the whole point.
>> It's a sort of macro facility for annotations. Obviously it looks extra
>> verbose if you just have one bean, but if you have many it's simpler.
>>
>
> Right. But I don't understand why is it an example of a problem with using
> @Stereotype...

Because of what the portable extension does.

It adds the annotations to MyOtherBean even though it wasn't there in the
source code.

By the time the portable extension runs to do that, the deployment process
will have already processed all the annotations that define components,
so the portable extension won't have the effect of defining MyOtherBean
as an EJB component.