[cdi-dev] Subclassing?

Stuart Douglas stuart.w.douglas at gmail.com
Mon Sep 17 17:31:00 EDT 2012



Mark Struberg wrote:
> The main difference we get from subclassing is that even 'internal invocations' (contrary to 'external invocations') will invoke the decorator method
>
> example
>
> public Class A implements X {
>
>
>    public void methA() {..}
>    public void methB() { methA(); }
>
> }
>
> @Decorator
> public class Adecorator implements X {
>    @Inject @Delegate X x;
>
>    public void methA();
> }
>
> If we do _not_ apply subclassing but proxying, then invoking methB will NOT trigger methA from Adecorator.
> If we DO force subclassing, then a call to methB will also trigger the decorator!
>
> But that is contrary to all other EE proxying behaviour so far...


In weld we currently use a thread local to work around this, so self 
invocation does not result in interceptors / decorators running again.

Stuart

>
>
> LieGrue,
> strub
>
>
>
> ----- Original Message -----
>> From: Pete Muir<pmuir at redhat.com>
>> To: Romain Manni-Bucau<rmannibucau at gmail.com>
>> Cc: "cdi-dev at lists.jboss.org"<cdi-dev at lists.jboss.org>
>> Sent: Monday, September 17, 2012 5:58 PM
>> Subject: Re: [cdi-dev] Subclassing?
>>
>> Romain,
>>
>> I agree, we can't specify to use subclassing. Please take a look at
>> https://github.com/jboss/cdi/pull/117 where I've tried to address this, in
>> terms of what effects people will see.
>>
>> On 17 Sep 2012, at 16:54, Romain Manni-Bucau wrote:
>>
>>>   Hi,
>>>
>>>   There is a bunch of jira to specify subclassing should be used in some
>> cases so i mail here instead of answering all jira.
>>>   IMO it is specifying too much the technical part:  specify the constructor
>> should be called twice is better for a spec IMHO (but this case is not logical
>> at all ;))
>>>   Why this need?
>>>
>>>   - Romain
>>>
>>>   _______________________________________________
>>>   cdi-dev mailing list
>>>   cdi-dev at lists.jboss.org
>>>   https://lists.jboss.org/mailman/listinfo/cdi-dev
>>
>> _______________________________________________
>> cdi-dev mailing list
>> cdi-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/cdi-dev
>>
>
> _______________________________________________
> cdi-dev mailing list
> cdi-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/cdi-dev


More information about the cdi-dev mailing list