2013-Proxy代理的使用

package itour.cn.fare.gateway;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.HashMap;
import java.util.Map;

public class ObeQueryProxy implements InvocationHandler{
    private Object target;
    
    public Object bind(Object target) {
        this.target = target;
        //取得代理对象
        return Proxy.newProxyInstance(target.getClass().getClassLoader(),
                target.getClass().getInterfaces(), this);  
    }

    @Override
    /**
     * 调用方法
     */
    public Object invoke(Object proxy, Method method, Object[] args)
            throws Throwable {
    
            result=method.invoke(target, args);

        }
        return result;
    }


}

原文地址:https://www.cnblogs.com/kuyuyingzi/p/4266316.html