`
roc08
  • 浏览: 224263 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

unproxy-a-spring-bean

 
阅读更多
http://stackoverflow.com/questions/8121551/is-it-possible-to-unproxy-a-spring-bean

http://stackoverflow.com/questions/4409456/how-to-unwrap-the-original-object-from-a-dynamic-proxy

http://www.techper.net/2009/06/05/how-to-acess-target-object-behind-a-spring-proxy/

http://jinnianshilongnian.iteye.com/blog/1613222

@SuppressWarnings({"unchecked"})
protected <T> T getTargetObject(Object proxy, Class<T> targetClass) throws Exception {
  if (AopUtils.isJdkDynamicProxy(proxy)) {
    return (T) ((Advised)proxy).getTargetSource().getTarget();
  } else {
    return (T) proxy; // expected to be cglib proxy then, which is simply a specialized class
  }
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics