class MyInvocationHandler implements InvocationHandler{
private static Service targetService;
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return null;
}
public static Service getProxyService(Service target){
targetService = target;
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
Class<?>[] interfaces = targetService.getClass().getInterfaces();
return (Service)Proxy.newProxyInstance(contextClassLoader,interfaces,new MyInvocationHandler());
}
}
忽然笑
相关分类