标签:and get ble target res port sys ade interface
1 package org.windwant.spring.core.proxy; 2 3 import java.lang.reflect.InvocationHandler; 4 import java.lang.reflect.Method; 5 import java.lang.reflect.Proxy; 6 7 /** 8 * Created by windwant on 2016/6/4. 9 */ 10 public class MyJDKProxy implements InvocationHandler{ 11 private Object targetObject; 12 public Object getInstance(Object targetObject){ 13 this.targetObject = targetObject; 14 return Proxy.newProxyInstance(targetObject.getClass().getClassLoader(), targetObject.getClass().getInterfaces(), this); 15 } 16 17 public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { 18 System.out.println("proxy: before action"); 19 Object resutl = method.invoke(targetObject, args); 20 System.out.println("proxy: after action"); 21 return resutl; 22 } 23 }
1 MyJDKProxy mp = new MyJDKProxy(); 2 XXX ap = (XXX) mp.getInstance(new APerformer()); 3 ap.XX();
标签:and get ble target res port sys ade interface
原文地址:http://www.cnblogs.com/niejunlei/p/5989848.html