Back Forum Reply New

Any hack to cast proxy to class?

Does anyone know of a way to cast a JdkDynamicAOPProxy to the class it is proxying?

I know, I know - use CGLIB.  But this is just for a test, and we're using autoproxying.

Is there ANY way to do it?

cheers,

David

What auto proxy are you using? With something like BeanNameAutoProxyCreator or DefaultAdvisorAutoProxyCreator, you can still set proxyTargetClass=true. This will force the use of CGLIB to generate a subclass and will allow casting to the implementation class.

Hope this helps.

Jess

yep, could do that - but don't really want to change all the proxying, just to allow us access to this class in the test.

That's why I was talking about quot;hacksquot; :-)

Will casting the delegate object work for you? Something like:

Code:
MyImpl proxiedObject = (MyImpl)((Advised)myBean).getTargetSource().getTarget();
-Ramnivas
¥
Back Forum Reply New