[webbeans-dev] Re: Stereotype inheritance proposal

Gavin King gavin.king at gmail.com
Wed Dec 3 10:07:51 EST 2008


The usecase: imagine that something like @Stateless is recharacterized  
as a stereotype and you want to apply it indirectly via the @action  
stereotype.

Sent from my iPhone

On Dec 3, 2008, at 5:32 AM, Pete Muir <pmuir at redhat.com> wrote:

>
> On 21 Nov 2008, at 18:07, Gavin King wrote:
>
>> oops forgot to attach the spec
>>
>> On Fri, Nov 21, 2008 at 1:05 PM, Gavin King <gavin at hibernate.org>  
>> wrote:
>>> I've got feedback from a number of people that stereotype  
>>> inheritance
>>> should be supported, and I agree with this feedback.
>
> I can't see a reason not to support it, except that stereotypes are  
> already very powerful, so without seeing use cases for which  
> stereotype inheritance is considerably simpler, I would say it's a  
> nice-to-have only.
>
>>>
>>>
>>> I think we should just do it in the simplest possible way and say
>>> simply that stereotype declarations are transitive, and
>>> meta-stereotypes are inherited by the web bean.
>>>
>>> Therefore:
>>>
>>> 1. the sets of interceptor binding types are unioned
>>> 2. any conflicts between default scope/deployment type defined by a
>>> stereotype and its meta-stereotypes must be resolved by explicit
>>> declaration on the web bean
>>> 3. all restrictions apply cumulatively
>>>
>>> And I've written this into section 2.7.1.5 of the attached spec  
>>> draft.
>>>
>>> Questions:
>>> ========
>>>
>>> Does anybody think that the default scope/deployment type declared
>>> directly by a stereotype should *override* the default
>>> scopes/deployment types declared by its meta-stereotypes? This rule
>>> makes a lot of sense, but it kinda makes things a little more  
>>> complex.
>>>
>>> For example:
>>>
>>> @RequestScoped
>>> @Stereotype
>>> public @interface Foo {}
>>>
>>> @SessionScoped
>>> @Foo
>>> @Stereotype
>>> public @interface Bar {}
>>>
>>> Should we force a web bean that declares @Bar to explicitly  
>>> specify a
>>> scope, or is it better to let @SessionScoped on Bar override
>>> @RequestScoped on Foo.
>
> I agree, it makes more sense for the stereotype to override the meta- 
> stereotype.
>
>>>
>>>
>>>
>>> Another thing I've just noticed, that applies to interceptor  
>>> bindings
>>> inherited by both stereotypes and other interceptor binding types,  
>>> is
>>> that you could potentially have a web bean with multiple "instances"
>>> of the same interceptor binding type - the same type, but different
>>> member values. I think we should say that this is a
>>> DefinitionException.
>>>
>>> For example:
>>>
>>> @Transactional(requiresNew=false)
>>> @Stereotype
>>> public @interface Foo {}
>>>
>>> @Transactional(requiresNew=true)
>>> @Stereotype
>>> public @interface Foo {}
>>>
>>> @Foo @Bar
>>> public class X {}
>>>
>>> Then X has both @Transactional(requiresNew=false) and
>>> @Transactional(requiresNew=true).
>>>
>>>
>>> --
>>> Gavin King
>>> gavin.king at gmail.com
>>> http://in.relation.to/Bloggers/Gavin
>>> http://hibernate.org
>>> http://seamframework.org
>>>
>>
>>
>>
>> -- 
>> Gavin King
>> gavin.king at gmail.com
>> http://in.relation.to/Bloggers/Gavin
>> http://hibernate.org
>> http://seamframework.org
>> <Web Beans  
>> 20081121.pdf>_______________________________________________
>> webbeans-dev mailing list
>> webbeans-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/webbeans-dev
>



More information about the weld-dev mailing list