import java.lang.reflect.Method;

import org.springframework.cglib.proxy.Enhancer;
import org.springframework.cglib.proxy.InvocationHandler;

import com.iamberry.wechat.core.entity.ProbationOrderUtil;


public class Test implements InvocationHandler {
	
	private Object targetObject;
	
	public Object createProxyObject(Object obj) { 
	    this.targetObject = obj; 
	    Enhancer enhancer = new Enhancer(); 
	    enhancer.setSuperclass(obj.getClass()); 
	    enhancer.setCallback(this); 
	    Object proxyObj = enhancer.create(); 
	    return proxyObj;// 返回代理对象，返回的对象其实就是一个封装了“实现类”的代理类，是实现类的实例。 
	}

	@Override
	public Object invoke(Object arg0, Method arg1, Object[] arg2)
			throws Throwable {
		System.out.println("....." + arg1.getName());
		arg1.invoke(targetObject, arg2);
		return null;
	} 
	
	public static void main(String[] args) {
		Test test = new Test();
		Object proxy = (ProbationOrderUtil) test.createProxyObject(new ProbationOrderUtil());
		System.out.println(proxy.getClass());
//		System.out.println(proxy.orderActin);
	}
}
