Have you ever been in a situation or you need to access the target object, proxied by Spring AOP or CGLIB ?
Yes?
Check out this obscure Interface that I’ve found in the Spring API:
org.springframework.aop.framework.Advised
Any AOP proxy obtained from Spring can be cast to this interface to allow manipulation of its AOP advice. With this in mind, you can track down the target object, and get the information you need.
Here’s an example:
Object myBean = yourSpringContext.getBean(beanName);
if(myBean instanceof Advised){
Advised advised = (Advised) actionBean;
// Get the target object: The proxied object
Object myObject = advised.getTargetSource().getTarget();
}