[seam-dev] Retrieving the Bean object for an interceptor

Stuart Douglas stuart at baileyroberts.com.au
Wed Apr 21 22:36:19 EDT 2010


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.
- Can I add a dependency on google collections to weld-extensions? Currently it stores the references in a syncronized WeakHashMap, but really what I need is a Concurrent Weak Identity hashmap. 

Hopefully this is just a temporary workaround that can be removed after the next release of the spec, but currently I can't see any other way to accomplish this.


Stuart


________________________________________
From: Pete Muir [pmuir at redhat.com]
Sent: Friday, 9 April 2010 9:24 PM
To: Nicklas Karlsson
Cc: Stuart Douglas; seam-dev at lists.jboss.org
Subject: Re: [seam-dev] Retrieving the Bean object for an interceptor

No, I think you are right Stuart. Sounds like something the MR should address.

On 6 Apr 2010, at 07:38, Nicklas Karlsson wrote:

> In the Good Old Days, say late 2008, when the spec was a draft for WebBeans, it said
>
> "If any class-level interceptor binding type is specified in XML, the interceptor binding annotations appearing on the implementation
> class are ignored. The class-level interceptor bindings for the Web Bean include all interceptor bindings declared
> using XML, together with all interceptor bindings of all stereotypes declared by the Web Bean.
>
> Otherwise, if no class-level interceptor binding types are specified in XML, the interceptor binding annotations that appear
> on the implementation class are used. The class-level interceptor bindings for the Web Bean include all interceptor bindings
> declared by annotating the implementation class, together with all interceptor bindings of all stereotypes declared by
> the Web Bean.
>
> If any method-level interceptor binding type is specified in XML, the interceptor binding annotations appearing on that
> method are ignored. The method-level interceptor bindings for that method include only the interceptor bindings declared
> using XML.
>
> Otherwise, if no method-level interceptor binding types are specified in XML, the interceptor binding annotations that appear
> on that method are used. The method-level interceptor bindings for that method include all the interceptor bindings
> declared by annotating the method."
>
>
>
> On Tue, Apr 6, 2010 at 7:56 AM, Stuart Douglas <stuart at baileyroberts.com.au> wrote:
> I can't see any way to get information about the actual Bean that an interceptor is bound to.
>
> For example say I have a class:
>
> @Security("#{true}")
> class SomeClass
> {
>   ...
> }
>
> Another bean with the same class is wired up with XML:
>
> <t:SomeClass>
>  <se:Security>#{false}</se:Security>
>  ....
> </t:SomeClass>
>
> I cannot see any way for a security interceptor to know which Bean it is intercepting, and therefore figure out which annotation to use. Is there something I am missing here?
>
> Stuart
> _______________________________________________
> seam-dev mailing list
> seam-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/seam-dev
>
>
>
> --
> ---
> Nik
> _______________________________________________
> seam-dev mailing list
> seam-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/seam-dev




More information about the seam-dev mailing list