首页 > 应用开发 > > 关于jdk 动态代理
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());
}
}关于jdk 动态代理 如果InvocationHandler中用静态方法有没有什么隐患
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2310/viewspace-3167436/ ,如需转载,请注明出处,否则将追究法律责任。