On Thu, Apr 22, 2010 at 12:38 AM, Marius Bogoevici
<marius.bogoevici(a)gmail.com> wrote:
On 10-04-21 10:36 PM, Stuart Douglas wrote:
> I have attempted to add a temporary fix for this issue to weld-extensions to allow
interceptors to get at the AnnotatedType of the object being intercepted.
>
> The extension wraps the InjectionTarget of Beans that need this functionality, and
the inject method of the InjectionTarget stores a mapping from the instance to the
AnnotatedType in a WeakHashMap.
>
> I have a few questions:
>
> - Is InvocationContext.getTarget() guaranteed to return the instance of the bean or
can it return a proxy? If it can return a proxy this technique is not going to work.
>
The Interceptor specification says just that "getTarget() returns the
associated target instance", so that would normally mean "the original
intercepted instance". The introduction of decorators made things more
complicated, and in the current implementation (1.0.1), getTarget() will
return the decorator proxy if the bean has both interceptors and
decorators.
Then that is a bug, since it is contrary to the specified behavior of
getTarget().
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 King
gavin.king(a)gmail.com
http://in.relation.to/Bloggers/Gavin
http://hibernate.org
http://seamframework.org