-
1. Re: Accessing class annotation on a Weld-made proxy?
ljnelson Oct 24, 2016 1:07 PM (in response to ljnelson)I see that https://issues.jboss.org/browse/CDI-10 is unresolved. Looks like I'll need to stick with the getClass().getSuperclass() hack.
-
2. Re: Accessing class annotation on a Weld-made proxy?
mkouba Oct 25, 2016 3:09 AM (in response to ljnelson)Hi Laird,
the spec calls the instance which is injected a contextual reference, for normal scoped beans you get a client proxy. Both these terms are well-defined (see also 6.5.3. Contextual reference for a bean and 5.4. Client proxies). Now back to the issue - since Weld 2.3 all the generated "proxy classes" have SYNTHETIC modifier so it's safe to walk the contextual reference class hierarchy and the first non-synthetic class is what you're looking for. The other non-portable solution would be to test
instanceof org.jboss.weld.bean.proxy.ProxyObject
(of course this would require compile-time dependency on Weld). -
3. Re: Accessing class annotation on a Weld-made proxy?
ljnelson Oct 25, 2016 10:51 AM (in response to mkouba)Martin Kouba wrote:
Hi Laird,
the spec calls the instance which is injected a contextual reference, for normal scoped beans you get a client proxy. Both these terms are well-defined (see also 6.5.3. Contextual reference for a bean and 5.4. Client proxies).
Now back to the issue - since Weld 2.3 all the generated "proxy classes" have SYNTHETIC modifier so it's safe to walk the contextual reference class hierarchy and the first non-synthetic class is what you're looking for. The other non-portable solution would be to test
instanceof org.jboss.weld.bean.proxy.ProxyObject
(of course this would require compile-time dependency on Weld).(I wasn't sure what your point was when you called attention to the definitions of contextual references and client proxies. I agree they're well-defined.)
I ended up using the isSynthetic() trick, which will certainly work in Weld; I'm too lazy to test it against other CDI implementations at the moment. :-)
Thanks,
Best,
Laird