JDK動(dòng)態(tài)代理詳解

JDK動(dòng)態(tài)代理詳解

java動(dòng)態(tài)代理類(lèi)

Java動(dòng)態(tài)代理類(lèi)位于java.lang.reflect包下譬涡,一般主要涉及到以下兩個(gè)類(lèi):

InvocationHandler

該類(lèi)是個(gè)接口荡澎,僅定義了一個(gè)方法

public interface InvocationHandler {

    /**
     * Processes a method invocation on a proxy instance and returns
     * the result.  This method will be invoked on an invocation handler
     * when a method is invoked on a proxy instance that it is
     * associated with.
     *
     * @param   proxy the proxy instance that the method was invoked on
     *
     * @param   method the {@code Method} instance corresponding to
     * the interface method invoked on the proxy instance.  The declaring
     * class of the {@code Method} object will be the interface that
     * the method was declared in, which may be a superinterface of the
     * proxy interface that the proxy class inherits the method through.
     *
     * @param   args an array of objects containing the values of the
     * arguments passed in the method invocation on the proxy instance,
     * or {@code null} if interface method takes no arguments.
     * Arguments of primitive types are wrapped in instances of the
     * appropriate primitive wrapper class, such as
     * {@code java.lang.Integer} or {@code java.lang.Boolean}.
     *
     * @return  the value to return from the method invocation on the
     * proxy instance.  If the declared return type of the interface
     * method is a primitive type, then the value returned by
     * this method must be an instance of the corresponding primitive
     * wrapper class; otherwise, it must be a type assignable to the
     * declared return type.  If the value returned by this method is
     * {@code null} and the interface method's return type is
     * primitive, then a {@code NullPointerException} will be
     * thrown by the method invocation on the proxy instance.  If the
     * value returned by this method is otherwise not compatible with
     * the interface method's declared return type as described above,
     * a {@code ClassCastException} will be thrown by the method
     * invocation on the proxy instance.
     *
     * @throws  Throwable the exception to throw from the method
     * invocation on the proxy instance.  The exception's type must be
     * assignable either to any of the exception types declared in the
     * {@code throws} clause of the interface method or to the
     * unchecked exception types {@code java.lang.RuntimeException}
     * or {@code java.lang.Error}.  If a checked exception is
     * thrown by this method that is not assignable to any of the
     * exception types declared in the {@code throws} clause of
     * the interface method, then an
     * {@link UndeclaredThrowableException} containing the
     * exception that was thrown by this method will be thrown by the
     * method invocation on the proxy instance.
     *
     * @see     UndeclaredThrowableException
     */
    public Object invoke(Object proxy, Method method, Object[] args)
        throws Throwable;
}

在實(shí)際使用時(shí)罪帖,第一個(gè)參數(shù)obj一般是指代理類(lèi)精盅,method是被代理的方法,args為該方法的參數(shù)數(shù)組。第一個(gè)參數(shù)基本上不會(huì)用到柳爽。

Proxy

該類(lèi)即為動(dòng)態(tài)代理類(lèi),其中主要包含以下內(nèi)容

  • protected Proxy(InvocationHandler h):構(gòu)造函數(shù)碱屁,用于給內(nèi)部的h賦值
  • static Class getProxyClass (ClassLoaderloader, Class[] interfaces):獲得一個(gè)代理類(lèi)磷脯,其中l(wèi)oader是類(lèi)裝載器,interfaces是真實(shí)類(lèi)所擁有的全部接口的數(shù)組
  • static Object newProxyInstance(ClassLoaderloader, Class[] interfaces, InvocationHandler h):返回代理類(lèi)的一個(gè)實(shí)例娩脾,返回后的代理類(lèi)可以當(dāng)作被代理類(lèi)使用(可使用被代理類(lèi)的在Subject接口中聲明過(guò)的方法)

在使用動(dòng)態(tài)代理類(lèi)時(shí)赵誓,我們必須實(shí)現(xiàn)InvocationHandler接口

動(dòng)態(tài)代理步驟
  1. 創(chuàng)建一個(gè)實(shí)現(xiàn)接口InvocationHandler的類(lèi),它必須實(shí)現(xiàn)invoke方法
  2. 創(chuàng)建被代理的類(lèi)以及接口
  3. 通過(guò)Proxy的靜態(tài)方法

? newProxyInstance(ClassLoaderloader, Class[] interfaces, InvocationHandler h)創(chuàng)建一個(gè)代理

  1. 通過(guò)代理調(diào)用方法
使用
  1. 需要?jiǎng)討B(tài)代理的接口
/**
 * @author  Date: 2017/5/16 Time: 10:30.
 */
public interface Student {
    void study();
}
  1. 需要代理的實(shí)際對(duì)象
/**
 * @author  Date: 2017/5/16 Time: 10:39.
 */
public class GoodStudent implements Student {
  public void study() {
    System.out.println("study hard");
  }
}
  1. 調(diào)用處理器實(shí)現(xiàn)類(lèi)
/**
 * @author  Date: 2017/5/16 Time: 10:37.
 */
public class ProxyHandler implements InvocationHandler {

  private Object student;

  public ProxyHandler(Object student) {
    this.student = student;
  }

  public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    System.out.println("hello before");
    Object result = method.invoke(student,args);
    System.out.println("bye after");
    return result;
  }
}

該調(diào)用處理器實(shí)現(xiàn)類(lèi)構(gòu)造函數(shù)接收一個(gè)Object對(duì)象柿赊。在invoke方法中method.invoke(student,args)是對(duì)被代理對(duì)象方法的調(diào)用俩功,在該調(diào)用前后分別輸出了語(yǔ)句。

  1. 測(cè)試
/**
 * @author  Date: 2017/5/16 Time: 10:31.
 */
public class ProxyTest {
  public static void main(String[] args) {
    GoodStudent goodStudent = new GoodStudent();
    Student proxyStudent =
        (Student) Proxy.newProxyInstance(Student.class.getClassLoader(),
            new Class[] {Student.class}, new ProxyHandler(goodStudent));
    proxyStudent.study();
  }
}

輸出

hello before
study hard
bye after

可以看到study hard是由goodStudy對(duì)象的study方法輸出的碰声,而前后的輸出則是調(diào)用處理器實(shí)現(xiàn)類(lèi)中增加的绑雄。

原理

從代碼中可以看出關(guān)鍵點(diǎn)在于以下這段代碼

Student proxyStudent =
        (Student) Proxy.newProxyInstance(Student.class.getClassLoader(),
            new Class[] {Student.class}, new ProxyHandler(goodStudent));

來(lái)看看newProxyInstance的源碼

 public static Object newProxyInstance(ClassLoader loader,
                                          Class<?>[] interfaces,
                                          InvocationHandler h)
        throws IllegalArgumentException
    {
        Objects.requireNonNull(h);

        final Class<?>[] intfs = interfaces.clone();
        final SecurityManager sm = System.getSecurityManager();
        if (sm != null) {
            checkProxyAccess(Reflection.getCallerClass(), loader, intfs);
        }

        /*
         * Look up or generate the designated proxy class.
         */
        //重點(diǎn)是cl怎么來(lái)的
        Class<?> cl = getProxyClass0(loader, intfs);

        /*
         * Invoke its constructor with the designated invocation handler.
         */
        try {
            if (sm != null) {
                checkNewProxyPermission(Reflection.getCallerClass(), cl);
            }
            //cons是cl類(lèi)的構(gòu)造函數(shù)
            final Constructor<?> cons = cl.getConstructor(constructorParams);
            final InvocationHandler ih = h;
            if (!Modifier.isPublic(cl.getModifiers())) {
                AccessController.doPrivileged(new PrivilegedAction<Void>() {
                    public Void run() {
                        cons.setAccessible(true);
                        return null;
                    }
                });
            }
            //最后返回的實(shí)例是由cons構(gòu)造函數(shù)構(gòu)造出來(lái)的
            return cons.newInstance(new Object[]{h});
        } catch (IllegalAccessException|InstantiationException e) {
            throw new InternalError(e.toString(), e);
        } catch (InvocationTargetException e) {
            Throwable t = e.getCause();
            if (t instanceof RuntimeException) {
                throw (RuntimeException) t;
            } else {
                throw new InternalError(t.toString(), t);
            }
        } catch (NoSuchMethodException e) {
            throw new InternalError(e.toString(), e);
        }
    }

可以看到該方法返回的實(shí)例是cl的構(gòu)造函數(shù)構(gòu)造出來(lái)的,那我們重點(diǎn)看看cl是怎么來(lái)的奥邮。

private static Class<?> getProxyClass0(ClassLoader loader,
                                           Class<?>... interfaces) {
        if (interfaces.length > 65535) {
            throw new IllegalArgumentException("interface limit exceeded");
        }

        // If the proxy class defined by the given loader implementing
        // the given interfaces exists, this will simply return the cached copy;
        // otherwise, it will create the proxy class via the ProxyClassFactory
        return proxyClassCache.get(loader, interfaces);
    }

可以看到這里對(duì)傳入的interfaces數(shù)組長(zhǎng)度有限制,不能超過(guò)65535.最后的數(shù)據(jù)都是從proxyClassCache緩存中獲取的罗珍,來(lái)看看這個(gè)緩存的定義洽腺。

private static final WeakCache<ClassLoader, Class<?>[], Class<?>>
        proxyClassCache = new WeakCache<>(new KeyFactory(), new ProxyClassFactory());

緩存中的對(duì)象則是由ProxyClassFactory構(gòu)造的。

private static final class ProxyClassFactory
        implements BiFunction<ClassLoader, Class<?>[], Class<?>>
    {
        // prefix for all proxy class names
        private static final String proxyClassNamePrefix = "$Proxy";

        // next number to use for generation of unique proxy class names
        private static final AtomicLong nextUniqueNumber = new AtomicLong();

        @Override
        public Class<?> apply(ClassLoader loader, Class<?>[] interfaces) {

            Map<Class<?>, Boolean> interfaceSet = new IdentityHashMap<>(interfaces.length);
            for (Class<?> intf : interfaces) {
                /*
                 * Verify that the class loader resolves the name of this
                 * interface to the same Class object.
                 */
                Class<?> interfaceClass = null;
                try {
                    interfaceClass = Class.forName(intf.getName(), false, loader);
                } catch (ClassNotFoundException e) {
                }
                if (interfaceClass != intf) {
                    throw new IllegalArgumentException(
                        intf + " is not visible from class loader");
                }
                /*
                 * Verify that the Class object actually represents an
                 * interface.
                 */
                if (!interfaceClass.isInterface()) {
                    throw new IllegalArgumentException(
                        interfaceClass.getName() + " is not an interface");
                }
                /*
                 * Verify that this interface is not a duplicate.
                 */
                if (interfaceSet.put(interfaceClass, Boolean.TRUE) != null) {
                    throw new IllegalArgumentException(
                        "repeated interface: " + interfaceClass.getName());
                }
            }

            String proxyPkg = null;     // package to define proxy class in
            int accessFlags = Modifier.PUBLIC | Modifier.FINAL;

            /*
             * Record the package of a non-public proxy interface so that the
             * proxy class will be defined in the same package.  Verify that
             * all non-public proxy interfaces are in the same package.
             */
            for (Class<?> intf : interfaces) {
                int flags = intf.getModifiers();
                if (!Modifier.isPublic(flags)) {
                    accessFlags = Modifier.FINAL;
                    String name = intf.getName();
                    int n = name.lastIndexOf('.');
                    String pkg = ((n == -1) ? "" : name.substring(0, n + 1));
                    if (proxyPkg == null) {
                        proxyPkg = pkg;
                    } else if (!pkg.equals(proxyPkg)) {
                        throw new IllegalArgumentException(
                            "non-public interfaces from different packages");
                    }
                }
            }

            if (proxyPkg == null) {
                // if no non-public proxy interfaces, use com.sun.proxy package
                proxyPkg = ReflectUtil.PROXY_PACKAGE + ".";
            }

            /*
             * Choose a name for the proxy class to generate.
             */
            long num = nextUniqueNumber.getAndIncrement();
            String proxyName = proxyPkg + proxyClassNamePrefix + num;

            /*
             * Generate the specified proxy class.
             */
            byte[] proxyClassFile = ProxyGenerator.generateProxyClass(
                proxyName, interfaces, accessFlags);
            try {
                return defineClass0(loader, proxyName,
                                    proxyClassFile, 0, proxyClassFile.length);
            } catch (ClassFormatError e) {
                /*
                 * A ClassFormatError here means that (barring bugs in the
                 * proxy class generation code) there was some other
                 * invalid aspect of the arguments supplied to the proxy
                 * class creation (such as virtual machine limitations
                 * exceeded).
                 */
                throw new IllegalArgumentException(e.toString());
            }
        }
    }

重點(diǎn)在于這一句

byte[] proxyClassFile = ProxyGenerator.generateProxyClass(
                proxyName, interfaces, accessFlags);

這一句生成了代理類(lèi)的字節(jié)碼覆旱。接下來(lái)我們著重分析該方法做了什么

generateProxyClass

我們可以將ProxyGenerator為我們生成的字節(jié)碼保存在磁盤(pán)中蘸朋,然后通過(guò)反編譯看看其實(shí)現(xiàn)。代碼如下:

/**
 * @author Date: 2017/5/16 Time: 10:31.
 */
public class ProxyTest {
  public static void main(String[] args) {
    createProxyClassFile();
  }

  public static void createProxyClassFile() {
    String name = "ProxyStudent";
    byte[] data = ProxyGenerator.generateProxyClass(name, new Class[] {Student.class});
    try {
      FileOutputStream out = new FileOutputStream(name + ".class");
      out.write(data);
      out.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}

上述代碼會(huì)替我們生成一個(gè)Student的代理類(lèi)扣唱,并保存在ProxyStudent.class文件中藕坯,類(lèi)名為ProxyStudent团南。

來(lái)看看反編譯后的結(jié)果

//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//


public final class ProxyStudent extends Proxy implements Student {
    private static Method m1;
    private static Method m3;
    private static Method m2;
    private static Method m0;

    public ProxyStudent(InvocationHandler var1) throws  {
        super(var1);
    }

    public final boolean equals(Object var1) throws  {
        try {
            return ((Boolean)super.h.invoke(this, m1, new Object[]{var1})).booleanValue();
        } catch (RuntimeException | Error var3) {
            throw var3;
        } catch (Throwable var4) {
            throw new UndeclaredThrowableException(var4);
        }
    }

    public final void study() throws  {
        try {
            super.h.invoke(this, m3, (Object[])null);
        } catch (RuntimeException | Error var2) {
            throw var2;
        } catch (Throwable var3) {
            throw new UndeclaredThrowableException(var3);
        }
    }

    public final String toString() throws  {
        try {
            return (String)super.h.invoke(this, m2, (Object[])null);
        } catch (RuntimeException | Error var2) {
            throw var2;
        } catch (Throwable var3) {
            throw new UndeclaredThrowableException(var3);
        }
    }

    public final int hashCode() throws  {
        try {
            return ((Integer)super.h.invoke(this, m0, (Object[])null)).intValue();
        } catch (RuntimeException | Error var2) {
            throw var2;
        } catch (Throwable var3) {
            throw new UndeclaredThrowableException(var3);
        }
    }

    static {
        try {
            m1 = Class.forName("java.lang.Object").getMethod("equals", new Class[]{Class.forName("java.lang.Object")});
            m3 = Class.forName("com.test.Student").getMethod("study", new Class[0]);
            m2 = Class.forName("java.lang.Object").getMethod("toString", new Class[0]);
            m0 = Class.forName("java.lang.Object").getMethod("hashCode", new Class[0]);
        } catch (NoSuchMethodException var2) {
            throw new NoSuchMethodError(var2.getMessage());
        } catch (ClassNotFoundException var3) {
            throw new NoClassDefFoundError(var3.getMessage());
        }
    }
}

可以看到該類(lèi)繼承了Proxy類(lèi),并實(shí)現(xiàn)了Student接口炼彪。這就是為什么我們能將其實(shí)例轉(zhuǎn)化為代理接口對(duì)象吐根。該類(lèi)包含了4個(gè)Method對(duì)象,并在靜態(tài)代碼快中初始化了這四個(gè)對(duì)象辐马。其中三個(gè)是繼承自O(shè)bject的方法:

  • m1:equals
  • m2:toString
  • m0:hashCode

m3才是我們自定義接口中的方法拷橘。

該類(lèi)的構(gòu)造函數(shù)接收一個(gè)InvocationHandler對(duì)象,并將其傳遞給了父類(lèi)Proxy喜爷。而該類(lèi)中所有方法的調(diào)用都直接扔給了Proxy類(lèi)中的InvocationHandler對(duì)象∪叽現(xiàn)在可以知道我們實(shí)現(xiàn)的InvocationHandler接口類(lèi)的實(shí)例的作用了。

流程

梳理下流程:

  1. 利用ProxyGenerator.generateProxyClass為被代理的類(lèi)(接口)生成代理類(lèi)(Proxy)
  2. 將實(shí)現(xiàn)的InvocationHandler對(duì)象作為代理類(lèi)的構(gòu)造函數(shù)參數(shù)傳遞進(jìn)去檩帐,得到代理類(lèi)實(shí)例
  3. 使用代理類(lèi)實(shí)例完成對(duì)被代理對(duì)象的代理

Mybatis中的應(yīng)用

mybatis中mapper的實(shí)現(xiàn)就利用了jdk動(dòng)態(tài)代理术幔。

核心類(lèi)

public class MapperProxyFactory<T> {

  private final Class<T> mapperInterface;
  private final Map<Method, MapperMethod> methodCache = new ConcurrentHashMap<Method, MapperMethod>();

  public MapperProxyFactory(Class<T> mapperInterface) {
    this.mapperInterface = mapperInterface;
  }

  public Class<T> getMapperInterface() {
    return mapperInterface;
  }

  public Map<Method, MapperMethod> getMethodCache() {
    return methodCache;
  }

  @SuppressWarnings("unchecked")
  protected T newInstance(MapperProxy<T> mapperProxy) {
    return (T) Proxy.newProxyInstance(mapperInterface.getClassLoader(), new Class[] { mapperInterface }, mapperProxy);
  }

  public T newInstance(SqlSession sqlSession) {
    final MapperProxy<T> mapperProxy = new MapperProxy<T>(sqlSession, mapperInterface, methodCache);
    return newInstance(mapperProxy);
  }

}

所有對(duì)Mapper的方法調(diào)用最終都代理給了MapperProxy。該類(lèi)的核心代碼如下:

public class MapperProxy<T> implements InvocationHandler, Serializable {

  @Override
  public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    try {
      if (Object.class.equals(method.getDeclaringClass())) {
        return method.invoke(this, args);
      } else if (isDefaultMethod(method)) {
        return invokeDefaultMethod(proxy, method, args);
      }
    } catch (Throwable t) {
      throw ExceptionUtil.unwrapThrowable(t);
    }
    final MapperMethod mapperMethod = cachedMapperMethod(method);
    return mapperMethod.execute(sqlSession, args);
  }
}

注意到該類(lèi)正是實(shí)現(xiàn)了InvocationHandler接口湃密。而自定義的方法最終都由mapperMethod來(lái)執(zhí)行了诅挑,接著mapperMethod又交給SqlSession來(lái)執(zhí)行了,細(xì)節(jié)請(qǐng)自行閱讀Mybatis源碼勾缭。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末揍障,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子俩由,更是在濱河造成了極大的恐慌毒嫡,老刑警劉巖,帶你破解...
    沈念sama閱讀 216,591評(píng)論 6 501
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件幻梯,死亡現(xiàn)場(chǎng)離奇詭異兜畸,居然都是意外死亡,警方通過(guò)查閱死者的電腦和手機(jī)碘梢,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,448評(píng)論 3 392
  • 文/潘曉璐 我一進(jìn)店門(mén)咬摇,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人煞躬,你說(shuō)我怎么就攤上這事肛鹏。” “怎么了恩沛?”我有些...
    開(kāi)封第一講書(shū)人閱讀 162,823評(píng)論 0 353
  • 文/不壞的土叔 我叫張陵在扰,是天一觀的道長(zhǎng)。 經(jīng)常有香客問(wèn)我雷客,道長(zhǎng)芒珠,這世上最難降的妖魔是什么? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 58,204評(píng)論 1 292
  • 正文 為了忘掉前任搅裙,我火速辦了婚禮皱卓,結(jié)果婚禮上裹芝,老公的妹妹穿的比我還像新娘。我一直安慰自己娜汁,他們只是感情好嫂易,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,228評(píng)論 6 388
  • 文/花漫 我一把揭開(kāi)白布。 她就那樣靜靜地躺著存炮,像睡著了一般炬搭。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上穆桂,一...
    開(kāi)封第一講書(shū)人閱讀 51,190評(píng)論 1 299
  • 那天宫盔,我揣著相機(jī)與錄音,去河邊找鬼享完。 笑死灼芭,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的般又。 我是一名探鬼主播彼绷,決...
    沈念sama閱讀 40,078評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼茴迁!你這毒婦竟也來(lái)了寄悯?” 一聲冷哼從身側(cè)響起,我...
    開(kāi)封第一講書(shū)人閱讀 38,923評(píng)論 0 274
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤堕义,失蹤者是張志新(化名)和其女友劉穎猜旬,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體倦卖,經(jīng)...
    沈念sama閱讀 45,334評(píng)論 1 310
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡洒擦,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,550評(píng)論 2 333
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了怕膛。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片熟嫩。...
    茶點(diǎn)故事閱讀 39,727評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖褐捻,靈堂內(nèi)的尸體忽然破棺而出掸茅,到底是詐尸還是另有隱情,我是刑警寧澤柠逞,帶...
    沈念sama閱讀 35,428評(píng)論 5 343
  • 正文 年R本政府宣布倦蚪,位于F島的核電站,受9級(jí)特大地震影響边苹,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜裁僧,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,022評(píng)論 3 326
  • 文/蒙蒙 一个束、第九天 我趴在偏房一處隱蔽的房頂上張望慕购。 院中可真熱鬧,春花似錦茬底、人聲如沸沪悲。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 31,672評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)殿如。三九已至,卻和暖如春最爬,著一層夾襖步出監(jiān)牢的瞬間涉馁,已是汗流浹背。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 32,826評(píng)論 1 269
  • 我被黑心中介騙來(lái)泰國(guó)打工爱致, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留烤送,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 47,734評(píng)論 2 368
  • 正文 我出身青樓糠悯,卻偏偏與公主長(zhǎng)得像帮坚,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子互艾,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,619評(píng)論 2 354

推薦閱讀更多精彩內(nèi)容

  • title: Jdk動(dòng)態(tài)代理原理解析 tags:代理 categories:筆記 date: 2017-06-14...
    行徑行閱讀 19,259評(píng)論 3 36
  • 原文: Dyanmic Proxy Classes 介紹 一個(gè)動(dòng)態(tài)代理類(lèi)是實(shí)現(xiàn)了多個(gè)接口存在于運(yùn)行時(shí)的類(lèi)试和,這樣,一...
    半黑月缺閱讀 942評(píng)論 0 0
  • 這篇博客主要介紹使用 InvocationHandler 這個(gè)接口來(lái)達(dá)到 hook 系統(tǒng) service 纫普,從而實(shí)...
    Shawn_Dut閱讀 5,085評(píng)論 0 33
  • 當(dāng)社會(huì)初始進(jìn)入階級(jí)之別時(shí)阅悍,就有統(tǒng)治階級(jí)與被統(tǒng)治階級(jí),就有為官與為民局嘁。當(dāng)今說(shuō)道做官溉箕,即公務(wù)員,想從事這一行的人還真不...
    城市屋檐下閱讀 2,395評(píng)論 0 1
  • 其實(shí)你沒(méi)有你母親想象的那么脆弱悦昵,只是你太依賴她了肴茄。 男人不是生活的全部,有了錦上添花但指,沒(méi)有了也不必強(qiáng)求寡痰。 我希望很...
    柳絮才高閱讀 315評(píng)論 0 0