Spring4.x源码解析:JDK动态代理成生成代理对象源码

@Component("aopTestBean")
class AopTestBean implements AopTestBeanInterface{
    public void aop1(){
        System.out.println("aop1");
    }
    
    public void aop2(){
        System.out.println("aop2");
    }
}

代理对象源码:

package com.sun.proxy;

import com.dk.spring.*;
import org.springframework.core.*;
import java.lang.reflect.*;
import org.springframework.aop.framework.*;
import org.springframework.aop.*;
import org.aopalliance.aop.*;

public final class $Proxy9 extends Proxy implements AopTestBeanInterface, SpringProxy, Advised, DecoratingProxy
{
    private static Method m1;
    private static Method m10;
    private static Method m14;
    private static Method m15;
    private static Method m20;
    private static Method m24;
    private static Method m5;
    private static Method m9;
    private static Method m17;
    private static Method m18;
    private static Method m0;
    private static Method m25;
    private static Method m23;
    private static Method m13;
    private static Method m16;
    private static Method m3;
    private static Method m4;
    private static Method m2;
    private static Method m27;
    private static Method m11;
    private static Method m28;
    private static Method m21;
    private static Method m6;
    private static Method m7;
    private static Method m22;
    private static Method m12;
    private static Method m26;
    private static Method m8;
    private static Method m19;
    
    public $Proxy9(final InvocationHandler invocationHandler) {
        super(invocationHandler);
    }
    
    public final boolean equals(final Object o) {
        try {
            return (boolean)super.h.invoke(this, $Proxy9.m1, new Object[] { o });
        }
        catch (Error | RuntimeException error) {
            throw;
        }
        catch (Throwable t) {
            throw new UndeclaredThrowableException(t);
        }
    }
    
    public final void addAdvisor(final Advisor advisor) throws AopConfigException {
        try {
            super.h.invoke(this, $Proxy9.m10, new Object[] { advisor });
        }
        catch (Error | RuntimeException error) {
            throw;
        }
        catch (Throwable t) {
            throw new UndeclaredThrowableException(t);
        }
    }
    
    public final boolean isExposeProxy() {
        try {
            return (boolean)super.h.invoke(this, $Proxy9.m14, null);
        }
        catch (Error | RuntimeException error) {
            throw;
        }
        catch (Throwable t) {
            throw new UndeclaredThrowableException(t);
        }
    }
    
    public final boolean isProxyTargetClass() {
        try {
            return (boolean)super.h.invoke(this, $Proxy9.m15, null);
        }
        catch (Error | RuntimeException error) {
            throw;
        }
        catch (Throwable t) {
            throw new UndeclaredThrowableException(t);
        }
    }
    
    public final void removeAdvisor(final int n) throws AopConfigException {
        try {
            super.h.invoke(this, $Proxy9.m20, new Object[] { n });
        }
        catch (Error | RuntimeException error) {
            throw;
        }
        catch (Throwable t) {
            throw new UndeclaredThrowableException(t);
        }
    }
    
    public final Class[] getProxiedInterfaces() {
        try {
            return (Class[])super.h.invoke(this, $Proxy9.m24, null);
        }
        catch (Error | RuntimeException error) {
            throw;
        }
        catch (Throwable t) {
            throw new UndeclaredThrowableException(t);
        }
    }
    
    public final int indexOf(final Advisor advisor) {
        try {
            return (int)super.h.invoke(this, $Proxy9.m5, new Object[] { advisor });
        }
        catch (Error | RuntimeException error) {
            throw;
        }
        catch (Throwable t) {
            throw new UndeclaredThrowableException(t);
        }
    }
    
    public final TargetSource getTargetSource() {
        try {
            return (TargetSource)super.h.invoke(this, $Proxy9.m9, null);
        }
        catch (Error | RuntimeException error) {
            throw;
        }
        catch (Throwable t) {
            throw new UndeclaredThrowableException(t);
        }
    }
    
    public final void addAdvice(final int n, final Advice advice) throws AopConfigException {
        try {
            super.h.invoke(this, $Proxy9.m17, new Object[] { n, advice });
        }
        catch (Error | RuntimeException error) {
            throw;
        }
        catch (Throwable t) {
            throw new UndeclaredThrowableException(t);
        }
    }
    
    public final void addAdvice(final Advice advice) throws AopConfigException {
        try {
            super.h.invoke(this, $Proxy9.m18, new Object[] { advice });
        }
        catch (Error | RuntimeException error) {
            throw;
        }
        catch (Throwable t) {
            throw new UndeclaredThrowableException(t);
        }
    }
    
    public final int hashCode() {
        try {
            return (int)super.h.invoke(this, $Proxy9.m0, null);
        }
        catch (Error | RuntimeException error) {
            throw;
        }
        catch (Throwable t) {
            throw new UndeclaredThrowableException(t);
        }
    }
    
    public final boolean isInterfaceProxied(final Class clazz) {
        try {
            return (boolean)super.h.invoke(this, $Proxy9.m25, new Object[] { clazz });
        }
        catch (Error | RuntimeException error) {
            throw;
        }
        catch (Throwable t) {
            throw new UndeclaredThrowableException(t);
        }
    }
    
    public final boolean removeAdvice(final Advice advice) {
        try {
            return (boolean)super.h.invoke(this, $Proxy9.m23, new Object[] { advice });
        }
        catch (Error | RuntimeException error) {
            throw;
        }
        catch (Throwable t) {
            throw new UndeclaredThrowableException(t);
        }
    }
    
    public final void setExposeProxy(final boolean b) {
        try {
            super.h.invoke(this, $Proxy9.m13, new Object[] { b });
        }
        catch (Error | RuntimeException error) {
            throw;
        }
        catch (Throwable t) {
            throw new UndeclaredThrowableException(t);
        }
    }
    
    public final void setTargetSource(final TargetSource targetSource) {
        try {
            super.h.invoke(this, $Proxy9.m16, new Object[] { targetSource });
        }
        catch (Error | RuntimeException error) {
            throw;
        }
        catch (Throwable t) {
            throw new UndeclaredThrowableException(t);
        }
    }
    
    public final void aop2() {
        try {
            super.h.invoke(this, $Proxy9.m3, null);
        }
        catch (Error | RuntimeException error) {
            throw;
        }
        catch (Throwable t) {
            throw new UndeclaredThrowableException(t);
        }
    }
    
    public final void aop1() {
        try {
            super.h.invoke(this, $Proxy9.m4, null);
        }
        catch (Error | RuntimeException error) {
            throw;
        }
        catch (Throwable t) {
            throw new UndeclaredThrowableException(t);
        }
    }
    
    public final String toString() {
        try {
            return (String)super.h.invoke(this, $Proxy9.m2, null);
        }
        catch (Error | RuntimeException error) {
            throw;
        }
        catch (Throwable t) {
            throw new UndeclaredThrowableException(t);
        }
    }
    
    public final Class getTargetClass() {
        try {
            return (Class)super.h.invoke(this, $Proxy9.m27, null);
        }
        catch (Error | RuntimeException error) {
            throw;
        }
        catch (Throwable t) {
            throw new UndeclaredThrowableException(t);
        }
    }
    
    public final void addAdvisor(final int n, final Advisor advisor) throws AopConfigException {
        try {
            super.h.invoke(this, $Proxy9.m11, new Object[] { n, advisor });
        }
        catch (Error | RuntimeException error) {
            throw;
        }
        catch (Throwable t) {
            throw new UndeclaredThrowableException(t);
        }
    }
    
    public final Class getDecoratedClass() {
        try {
            return (Class)super.h.invoke(this, $Proxy9.m28, null);
        }
        catch (Error | RuntimeException error) {
            throw;
        }
        catch (Throwable t) {
            throw new UndeclaredThrowableException(t);
        }
    }
    
    public final boolean removeAdvisor(final Advisor advisor) {
        try {
            return (boolean)super.h.invoke(this, $Proxy9.m21, new Object[] { advisor });
        }
        catch (Error | RuntimeException error) {
            throw;
        }
        catch (Throwable t) {
            throw new UndeclaredThrowableException(t);
        }
    }
    
    public final int indexOf(final Advice advice) {
        try {
            return (int)super.h.invoke(this, $Proxy9.m6, new Object[] { advice });
        }
        catch (Error | RuntimeException error) {
            throw;
        }
        catch (Throwable t) {
            throw new UndeclaredThrowableException(t);
        }
    }
    
    public final boolean isFrozen() {
        try {
            return (boolean)super.h.invoke(this, $Proxy9.m7, null);
        }
        catch (Error | RuntimeException error) {
            throw;
        }
        catch (Throwable t) {
            throw new UndeclaredThrowableException(t);
        }
    }
    
    public final boolean replaceAdvisor(final Advisor advisor, final Advisor advisor2) throws AopConfigException {
        try {
            return (boolean)super.h.invoke(this, $Proxy9.m22, new Object[] { advisor, advisor2 });
        }
        catch (Error | RuntimeException error) {
            throw;
        }
        catch (Throwable t) {
            throw new UndeclaredThrowableException(t);
        }
    }
    
    public final void setPreFiltered(final boolean b) {
        try {
            super.h.invoke(this, $Proxy9.m12, new Object[] { b });
        }
        catch (Error | RuntimeException error) {
            throw;
        }
        catch (Throwable t) {
            throw new UndeclaredThrowableException(t);
        }
    }
    
    public final String toProxyConfigString() {
        try {
            return (String)super.h.invoke(this, $Proxy9.m26, null);
        }
        catch (Error | RuntimeException error) {
            throw;
        }
        catch (Throwable t) {
            throw new UndeclaredThrowableException(t);
        }
    }
    
    public final Advisor[] getAdvisors() {
        try {
            return (Advisor[])super.h.invoke(this, $Proxy9.m8, null);
        }
        catch (Error | RuntimeException error) {
            throw;
        }
        catch (Throwable t) {
            throw new UndeclaredThrowableException(t);
        }
    }
    
    public final boolean isPreFiltered() {
        try {
            return (boolean)super.h.invoke(this, $Proxy9.m19, null);
        }
        catch (Error | RuntimeException error) {
            throw;
        }
        catch (Throwable t) {
            throw new UndeclaredThrowableException(t);
        }
    }
    
    static {
        try {
            $Proxy9.m1 = Class.forName("java.lang.Object").getMethod("equals", Class.forName("java.lang.Object"));
            $Proxy9.m10 = Class.forName("org.springframework.aop.framework.Advised").getMethod("addAdvisor", Class.forName("org.springframework.aop.Advisor"));
            $Proxy9.m14 = Class.forName("org.springframework.aop.framework.Advised").getMethod("isExposeProxy", (Class<?>[])new Class[0]);
            $Proxy9.m15 = Class.forName("org.springframework.aop.framework.Advised").getMethod("isProxyTargetClass", (Class<?>[])new Class[0]);
            $Proxy9.m20 = Class.forName("org.springframework.aop.framework.Advised").getMethod("removeAdvisor", Integer.TYPE);
            $Proxy9.m24 = Class.forName("org.springframework.aop.framework.Advised").getMethod("getProxiedInterfaces", (Class<?>[])new Class[0]);
            $Proxy9.m5 = Class.forName("org.springframework.aop.framework.Advised").getMethod("indexOf", Class.forName("org.springframework.aop.Advisor"));
            $Proxy9.m9 = Class.forName("org.springframework.aop.framework.Advised").getMethod("getTargetSource", (Class<?>[])new Class[0]);
            $Proxy9.m17 = Class.forName("org.springframework.aop.framework.Advised").getMethod("addAdvice", Integer.TYPE, Class.forName("org.aopalliance.aop.Advice"));
            $Proxy9.m18 = Class.forName("org.springframework.aop.framework.Advised").getMethod("addAdvice", Class.forName("org.aopalliance.aop.Advice"));
            $Proxy9.m0 = Class.forName("java.lang.Object").getMethod("hashCode", (Class<?>[])new Class[0]);
            $Proxy9.m25 = Class.forName("org.springframework.aop.framework.Advised").getMethod("isInterfaceProxied", Class.forName("java.lang.Class"));
            $Proxy9.m23 = Class.forName("org.springframework.aop.framework.Advised").getMethod("removeAdvice", Class.forName("org.aopalliance.aop.Advice"));
            $Proxy9.m13 = Class.forName("org.springframework.aop.framework.Advised").getMethod("setExposeProxy", Boolean.TYPE);
            $Proxy9.m16 = Class.forName("org.springframework.aop.framework.Advised").getMethod("setTargetSource", Class.forName("org.springframework.aop.TargetSource"));
            $Proxy9.m3 = Class.forName("com.dk.spring.AopTestBeanInterface").getMethod("aop2", (Class<?>[])new Class[0]);
            $Proxy9.m4 = Class.forName("com.dk.spring.AopTestBeanInterface").getMethod("aop1", (Class<?>[])new Class[0]);
            $Proxy9.m2 = Class.forName("java.lang.Object").getMethod("toString", (Class<?>[])new Class[0]);
            $Proxy9.m27 = Class.forName("org.springframework.aop.framework.Advised").getMethod("getTargetClass", (Class<?>[])new Class[0]);
            $Proxy9.m11 = Class.forName("org.springframework.aop.framework.Advised").getMethod("addAdvisor", Integer.TYPE, Class.forName("org.springframework.aop.Advisor"));
            $Proxy9.m28 = Class.forName("org.springframework.core.DecoratingProxy").getMethod("getDecoratedClass", (Class<?>[])new Class[0]);
            $Proxy9.m21 = Class.forName("org.springframework.aop.framework.Advised").getMethod("removeAdvisor", Class.forName("org.springframework.aop.Advisor"));
            $Proxy9.m6 = Class.forName("org.springframework.aop.framework.Advised").getMethod("indexOf", Class.forName("org.aopalliance.aop.Advice"));
            $Proxy9.m7 = Class.forName("org.springframework.aop.framework.Advised").getMethod("isFrozen", (Class<?>[])new Class[0]);
            $Proxy9.m22 = Class.forName("org.springframework.aop.framework.Advised").getMethod("replaceAdvisor", Class.forName("org.springframework.aop.Advisor"), Class.forName("org.springframework.aop.Advisor"));
            $Proxy9.m12 = Class.forName("org.springframework.aop.framework.Advised").getMethod("setPreFiltered", Boolean.TYPE);
            $Proxy9.m26 = Class.forName("org.springframework.aop.framework.Advised").getMethod("toProxyConfigString", (Class<?>[])new Class[0]);
            $Proxy9.m8 = Class.forName("org.springframework.aop.framework.Advised").getMethod("getAdvisors", (Class<?>[])new Class[0]);
            $Proxy9.m19 = Class.forName("org.springframework.aop.framework.Advised").getMethod("isPreFiltered", (Class<?>[])new Class[0]);
        }
        catch (NoSuchMethodException ex) {
            throw new NoSuchMethodError(ex.getMessage());
        }
        catch (ClassNotFoundException ex2) {
            throw new NoClassDefFoundError(ex2.getMessage());
        }
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值