首页  

spring aop cglib 代理类源码查看     所属分类 spring 浏览量 1213
System.setProperty(DebuggingClassWriter.DEBUG_LOCATION_PROPERTY, "/Users/dugang/work/cglib"); 
System.setProperty("sun.misc.ProxyGenerator.saveGeneratedFiles", "true");  
		
org.springframework.cglib.core.DebuggingClassWriter

日志输出 
CGLIB debugging enabled, writing to '/Users/dugang/work/cglib'


dugang:cglib dugang$ find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
.
|____aop
| |____Config$$EnhancerBySpringCGLIB$$9c75c227.class
| |____InternalInvokeTest$$EnhancerBySpringCGLIB$$89bf4ff2$$FastClassBySpringCGLIB$$8076a689.class
| |____InternalInvokeTest$$EnhancerBySpringCGLIB$$89bf4ff2.class
| |____InternalInvokeTest$$FastClassBySpringCGLIB$$d2ca5b53.class
| |____PetCat$$EnhancerBySpringCGLIB$$1339d311.class
| |____PetTiger$$EnhancerBySpringCGLIB$$239f21ac.class
|____org
| |____springframework
| | |____cglib
| | | |____core
| | | | |____MethodWrapper$MethodWrapperKey$$KeyFactoryByCGLIB$$552be97a.class
| | | |____proxy
| | | | |____Enhancer$EnhancerKey$$KeyFactoryByCGLIB$$4ce19e8f.class



使用 JD-GUI 反编译 class 文件 

Config$$EnhancerBySpringCGLIB$$9c75c227.class
InternalInvokeTest$$EnhancerBySpringCGLIB$$89bf4ff2.class


普通代理类 方法 调用 super.xxx , 因此内部调用 无法拦截


 public final void method1()
  {
    try
    {
      MethodInterceptor tmp4_1 = this.CGLIB$CALLBACK_0;
      if (tmp4_1 == null)
      {
        tmp4_1;
        CGLIB$BIND_CALLBACKS(this);
      }
      if (this.CGLIB$CALLBACK_0 != null) {
        return;
      }
      // note here !!!!!!
      super.method1();
      return;
    }
    catch (RuntimeException|Error localRuntimeException)
    {
      throw localRuntimeException;
    }
    catch (Throwable localThrowable)
    {
      throw new UndeclaredThrowableException(localThrowable);
    }
  }

上一篇     下一篇
基于Aspect注解的spring aop 实例

AOP知识点

spring aop 内部方法调用拦截说明

Properties使用UTF8读取中文配置文件

spring5自动装配实例

eclipse异常断点设置