Accessing Spring Proxies - Reflection and Advised
a reoccuring issue that i've struck when using Spring is trying to work with a proxied object in reflection. it's not something that occurs all the time, and there's very smart people doing very smart things with this, but here's what i've found works… Advised
basically, when you retrieve an object that's been proxied by Spring, it can be cast to an Advised object that can then be used to retrieve the underlying object.
if you execute the underlying object though, you don't get the advantage of whatever aspect you had added so beware of that.
in any event, here's the code to get a quick sample up and running.
here's our holder
here's the proxied class
here's our aspect
and here's our context XML
now, finally, the test that shows what can be done
No comments:
Post a Comment