package com.thinker.common.proxy;

import java.lang.reflect.Proxy;

/**
 * Created by lzh on 8/3/16.
 * 练习动态代理的使用
 *
 */
public class TestDynamicProxy {

    private static void dynamicProxy() throws IllegalAccessException, InstantiationException {
        Handler log = new Handler<>(FatherImpl.class);
        Father proxy = (Father) Proxy.newProxyInstance(Father.class.getClassLoader(),
                FatherImpl.class.getInterfaces(),log);
        proxy.say();
    }

    public static void main(String[] args) {
        try {
            dynamicProxy();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        }
    }
}
