[weld-dev] Question for EG, was: Retrieving the Bean object for an interceptor

Marius Bogoevici marius.bogoevici at gmail.com
Thu Apr 29 12:30:55 EDT 2010


On 10-04-22 1:44 AM, Gavin King wrote:
> On Thu, Apr 22, 2010 at 12:38 AM, Marius Bogoevici
> <marius.bogoevici at gmail.com>  wrote:
>    
>> However, once we move to subclassing (1.0.2), the call will
>> return the single instrumented instance, which is essentially a subclass
>> of the bean class. It would be necessary to retrieve the original bean
>> class from that. But I can see a few options for doing that, one being a
>> mixin interface with methods that can retrieve information about the
>> original type of the target object.
>>      
> Hrm. That's a problem I had not thought of with the subclassing
> approach. The assumption in EJB is that getTarget() returns an
> unintercepted/undecorated reference. Urm.
>
>    
Gavin,

This is not the same issue, but still related to what is 
decorated/intercepted in CDI. Is it possible to clarify the following 
from the EG's point of view:

Consider the following bean:

class SomeBean
{

     @Binding
     void method1() {}

     @Binding
     void method2()
     {
         method1();
     }
}

The question is whether upon invoking method2(), the subsequent 
invocation to method1() must be intercepted as well.  While this hasn't 
been possible while using proxies, the question becomes actual in the 
context of subclassing. It has also been raised by users recently.

The specification says that only business method invocations on 
contextual references must be intercepted, so the main question here is 
whether we should treat *this* as a contextual reference. While I'm not 
sold entirely either way, I can see a lot more reasons why 
this.method1() would not be intercepted upon invoking method2(), the 
idea being that interceptors/decorators are container-level entities 
which are applied on the "contextual reference" and not on the POJO bean 
itself, which would also be consistent with the way things are done in 
EJB. Also, if we allow interception in this case, then the invocation to 
method1() would also need to be decorated, which IMO can lead to 
unexpected side-effects.

Pete and I have discussed this,  and since the current subclassing 
approach opens the door to an interpretation where method invocations on 
"this" are also decorated and intercepted, we decided that the best 
course of action is to address the EG for clarifications. 
Implementation-wise, it can be done either way.

Thanks,
Marius




More information about the weld-dev mailing list