-
1. Re: Original class (instance) of a CDI proxy?
luksa Jan 25, 2013 7:01 AM (in response to kwutzke)1 of 1 people found this helpfulIt would be best to find an alternative way, but if you really need to do this and you don't mind depending on Weld directly, you can cast your proxy object to org.jboss.weld.interceptor.util.proxy.TargetInstanceProxy and invoke getTargetClass() on it.
Of course this would be very fragile and could break with a new version of Weld.
-
2. Re: Original class (instance) of a CDI proxy?
luksa Jan 25, 2013 7:15 AM (in response to luksa)You can also probably simply do proxyObject.getClass().getSuperClass(), but again this is very very fragile.
-
3. Re: Original class (instance) of a CDI proxy?
kwutzke Jan 25, 2013 12:03 PM (in response to luksa)This does what I wanted, thanks. Strange that it's getSuperclass()...
Why is it so "fragile"??
-
4. Re: Original class (instance) of a CDI proxy?
alesj Jan 25, 2013 12:13 PM (in response to kwutzke)Strange that it's getSuperclass()...
Weld proxies use Javassist, which sets original class as super class when creating proxy classes.
This way you can still reference it - the proxy - as your original class; aka left side is your class.
Why is it so "fragile"??
It's an implementation detail.